Custom sorting in data grid

Sorting entire records
Problem:
Assume you have an array of 20 items (master array), and
first 5 items are pulled into another array (paged array),
Which is the dataprovider for the datagrid. And the datagrid
has 10 columns.
When the user sorts on the datagrid, sorting should happen on
the 20 records, and
Not on the 5 records.
What i tried:
Clicking on a datagrid column header will sort only the data
provider of the datagrid. i.e., the
5 records. In order to sort all 20 records, sorting should
take place on the master array,
and not on the paged array. Sorting on 20 items seems to be
impossible.
The only logic we could think of was that, on the
headerRelease of datagrid, capture the
column header clicked(not sure if you can capture it or not).
And write custom function
for sorting based on that column. Since there are 10 columns,
the number of functions
or number of blocks of code to be written will Be 10. So did
not feel to be feasible and optimal solution.
Please advice.

Hello chhavs,
If you listen to the DataGrid's headerRelease event, the event has a property columnIndex to let you know which column the user wanted to sort. So you don't need 10 functions, just one with a switch statement, which is reasonable.
private function handleHeaderRelease(event:DataGridEvent):void
var sort:Sort = new Sort();
var field:SortField;
switch (event.columnIndex)
case 0:
field = new SortField("fieldA");
break;
case 1:
field = new SortField("fieldB");
break;
case ...
sort.fields = [field];
masterRecords.sort = sort;
masterRecords.refresh();
Thanks,
Philip

Similar Messages

  • Custom Sort (by date) in a DataGrid component

    So I've got a data grid component hooked up to a data provider like so:
    var weekData:XML=// some xml loaded in earlier....
    var weekGrid:DataGrid=new DataGrid();
    var dataProvider:DataProvider=new DataProvider();
    for each(var entry:XML in weekData){
         dp.addItem({event:entry.title,date:FormatDate.format(new Date(entry.@startDate),5),data:entry.@startDate});
    The title column is just what you might think. The date colum is actually a format like May 2012 or Feb 2013. And the data "column" isn't actually shown in the dataGrid it is the "key" for sorting by date. It contains the getTime() value of the date like 1328515200000. So that will make date sorting just a case of Array.NUMERIC with the appropriate Array.DESCENDING when needed.
    I've found that if I do this:
    weekGrid.dataProvider.sortOn("data",Array.NUMERIC)
    weekGrid.invalidate();
    it works and the grid is sorted -- IF I have some other button to click to cause that code to run.
    I want to tie it together with the click event on the grid header. Thusly:
    weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
    And I've getting the event and all, but evidently that is fireing off the built-in sorting which happens after mine. And it doesn't do what I want.
    Any idea how to stop that and allow my perferred sorting to take place?

    if you don't want the user to sort your datagrid, use:
    weekGrid.sortableColumns = false;
    and execute your sort without clicking anything.  or use:
    weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
    function sortDataGrid(e:DataGridEvent):void{
        setTimeout(sortF,100);
    function sortF():void{
        weekGrid.dataProvider.sortOn("data",Array.NUMERIC)

  • WAD - how to design custom sorting of data?

    Hi,
    I have an analysis web item which is mapped to a query i.e a single data provider DP1.
    I have a requirement of disabling the pop up menu that appears on column right click of the report. I have done so. However, I require the sorting feature to be made available to the users. For this I have used a button & selected 'Set Sorting' command from under Characteristics. However, this lets me set sorting only for onw column & cannot be configured as toggle action.
    Plz. let me know how can I implement sorting feature on all columns of the report w/o having the pop-up menu OR if there is a way to have the pop-up menu only display sort option alone.
    Thanks.

    Hi,
    the af:column allows you to group columns
    <af:column>
    <af:column> </af:column>
    <af:column> </af:column>
    </af:clomn>
    Also, in HTML it is easy to assign a background color to cell, e.g. cell with Label 1 is red, Label 2 is green.
    Is there something like this in JSF?
    You can use CSS on the inlineStyl or contentStyle property to dynamically set CSS using EL. You can reference e.g. a managed bean , access the #{row} variable within the managed bean method and return the color based on the value you read for the each row
    Frank

  • Custom System Data Grid

    Hi!
    I need a custom data grid, explaining:
    I need to made custom list of specific files, in the System data grid I can use the drag and drop files to desktop, but how I made the drag and drop work in the custom data grid of list of files?
    I tried to show in the data grid the path of the file, and drag this, but the error is:
    "Data for file list format must be an array of Files"
    But, how I made a "array of files"?
    Sorry to my bad english =)
    Thanks a lot! =)

    Hello chhavs,
    If you listen to the DataGrid's headerRelease event, the event has a property columnIndex to let you know which column the user wanted to sort. So you don't need 10 functions, just one with a switch statement, which is reasonable.
    private function handleHeaderRelease(event:DataGridEvent):void
    var sort:Sort = new Sort();
    var field:SortField;
    switch (event.columnIndex)
    case 0:
    field = new SortField("fieldA");
    break;
    case 1:
    field = new SortField("fieldB");
    break;
    case ...
    sort.fields = [field];
    masterRecords.sort = sort;
    masterRecords.refresh();
    Thanks,
    Philip

  • Sort functionality in Data Grid

    Hi Gurus,
    I am new to this DataGrid control.I want to establish the sort functionality when clicking on the headercolumns as in matrices.
    (ie.When double clicking the header column , sort the data in ascending or descending order of that column) like in system form matrices.
    How ever this is not possible when I tried with grid control.
    The problem I am facing is that I cannot get the column headers of the grid programmatically.(in duble click event or itempressed event)
    Anybody did this one previously? Also how
    we can change the column order of the grid using screen painter?
    The columns that actually come visible in the grid  are actually columns of the linked datatable object.
    In the designer ,there is no "swap" button for column re-ordering.
    Only one way I know is changing the query associated with datatable.
    This is a crucial thing ,since client may ask for re-ordering of columns frequently.
    Can anybody help?
    Regards,
    Deepesh

    Hi Deepesh,
    1. This functionality is not available with the SDK. Thus it's not possible to change it on the fly. Your only option is to change the query associated with datatable (as you mentioned). You may set up a user preference table, that the user can configure with its preference. That's the best you can do.
    2. To swap the columns in screen painter you must use SBO 2005 (it's not available on previous release). What you must do is, click on the one column you want to swap and the other you want to swap and click on the swap button (on the left bottom of the page in the columns tab)

  • My custom Tool tip on spark data Grid don't work ?

    I want to add panel component as my tooltip for each row in my Spark DataGrid. So when mouse rollover the user can see the information for each the ship. I want a panel as my tooltip for dataGrid cause I want to organize my data neatly and also place a image in the panel.
    I came across :http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf60d65-7ff6.html  where they show an example of "Implementing the IToolTip interface" using the panel.I tried manipulating the codes but it didt work for my spark dataGrid.
    So my question :
    Can some one pls show me how I can use the Panel as my tool tip for each row in spark data grid.
    I have been struggling for quite some time.If possible pls Give me an example.
    This is my codes below (I tried to follow the example from :http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf60d65-7ff6.html#WS2d b454920e96a9e51e63e3d11c0bf60d65-7ff4 -"Implementing the IToolTip interface")
    My MXML Application codes :
        <fx:Script>
        <![CDATA[
            import DesignItemRenderer.PanelToolTip;
            import mx.events.ToolTipEvent;
            import mx.collections.ArrayCollection;         
            import mx.controls.Alert;  
            import spark.events.GridEvent; 
            [Bindable]
            private var myArrivalShips:ArrayCollection = new ArrayCollection([
                {arrivalShipsName:"Ship A", ETD:"12 March"},
                {arrivalShipsName:"Ship B", ETD:"25 March"}            
            private function createCustomTip(event:ToolTipEvent):void {
                var ptt:PanelToolTip = new PanelToolTip();
                ptt.title = "my Ship Info";
                ptt.bodyText = "my data for the ship";
                event.toolTip = ptt;
        ]]>
    </fx:Script>
    <s:BorderContainer x="267" y="11" width="331" height="586">
        <s:DataGrid id="arrivalTable" x="10" y="326" width="302" height="205" requestedRowCount="4" dataProvider="{myArrivalShips}" toolTipCreate="createCustomTip(event)">
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn dataField="arrivalShipsName" headerText="Arrival Ships" ></s:GridColumn>
                    <s:GridColumn dataField="ETD" headerText="ETD"></s:GridColumn>             
                </s:ArrayList>
            </s:columns>           
        </s:DataGrid>
        <s:BorderContainer x="10" y="19" width="302" height="285">
        </s:BorderContainer>
    </s:BorderContainer>
    My Custom Panel codes :
    <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
         implements="mx.core.IToolTip" >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            [Bindable]
            public var bodyText:String = "";
            //  Implement required methods of the IToolTip interface; these
            //  methods are not used in this example, though.
            public var _text:String;
            public function get text():String {
                return _text;
            public function set text(value:String):void {
        ]]>
    </fx:Script>
    <s:RichText text="{bodyText}" percentWidth="100"/>
    </s:Panel>

    Ok I was getting ready to post the renderer code and then found the problem. I had copied this code from another renderer which had contentBackgroundAlpha=0 in the MXAdvancedDataGridItemRenderer tag. When I removed it, the style of the TextArea worked as intended. Your comment helped me to take a closer look at the renderer code, so thank you.

  • Sort on views in data grid (ORA-00904)

    Can anyone else confirm that this happens, or has been highlighted previously:
    1. Connect to any schema containing views
    2. Expand the views tree
    3. Click on any view
    4. Click on the data tab to display the data grid
    5. Click the sort button
    6. Select any column (must not exist in view selected later)
    7. Click "Apply Sort"
    8. Now click on any other view that does not contain a column of the same name as the one chosen as the sort column previously.
    I receive an ORA-00904 error. The only way I can clear this is to close down the data grid tab item, and re-open it.
    Cheers
    Carl
    DBA - Dunfermline Building Society

    Yes.
    Login as a DBA.
    Go to Other Users - SYS - Views - More - Filter - %% - OK
    Click on DBA_USERS - DATA - Sort - USERNAME - Apply Sort
    Click on DBA_USTATS
    --> ORA-00904 "USERNAME". invalid identifier.
    Notice that the columns in the data view have not changed.
    Close the tab and click on DBA_USTATS fixes the problem (no data anyway).
    Click on freeze view (the push pin) and click on DBA_USTATS fixes the problem.
    These are two easy workarounds, but it is confusing the first time you encounter it.

  • Advanced Data Grid Sorting / Grouping Collection

    Ok, basically here's the issue..
    I have an advanced data grid with a tree view. It goes two
    levels deep
    so:
    Report Type
    |-------------------- Company
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    |-------------------- Company 2
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    Report Type 2
    |-------------------- Company
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    |-------------------- Company 2
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    etc..
    Report and Company are Nodes (folders) and are being sorted
    alphabetically by default.
    The individual reports (Report 1,2,3, etc..) are not being
    sorted in any way that I can figure out. I need to sort them by
    date, but no matter what I've tried I can't get it to work.
    I tried a SortCompareFunction on the advancedDataGridColumn
    that displays each report, and it works *IF* I click the header...
    but if I dispatch the header_release event via AS3, nothing
    happens.
    I even set up a test:
    dg.addEventListener(AdvancedDataGridEvent.HEADER_RELEASE,heard);
    dg.dispatchEvent(
    new AdvancedDataGridEvent
    AdvancedDataGridEvent.HEADER_RELEASE,
    false,
    true,
    0, // The zero-based index of the column to sort in the
    DataGrid object's columns array.
    null,
    0,
    null,
    null,
    0
    function heard(e:Event) {
    trace("I HEAR IT!");
    trace(e.type);
    I set that up on a button so I can dispatch the event with a
    click. Every time I click the button, the header release event
    listener goes off, but the actual advanceddatagrid remains
    unchanged until I actually click on it's header..
    Any help would be *GREATLY* appreciated... I've been stuck on
    this problem for two days now :(

    "AnakinJay" <[email protected]> wrote in
    message
    news:[email protected]...
    > Ok, basically here's the issue..
    >
    > I have an advanced data grid with a tree view. It goes
    two levels deep
    > so:
    > Report Type
    > |-------------------- Company
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > |-------------------- Company 2
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    >
    > Report Type 2
    > |-------------------- Company
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > |-------------------- Company 2
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > etc..
    >
    > Report and Company are Nodes (folders) and are being
    sorted alphabetically
    > by
    > default.
    > The individual reports (Report 1,2,3, etc..) are not
    being sorted in any
    > way
    > that I can figure out. I need to sort them by date, but
    no matter what
    > I've
    > tried I can't get it to work.
    >
    > I tried a SortCompareFunction on the
    advancedDataGridColumn that displays
    > each
    > report, and it works *IF* I click the header... but if I
    dispatch the
    > header_release event via AS3, nothing happens.
    >
    > I even set up a test:
    >
    dg.addEventListener(AdvancedDataGridEvent.HEADER_RELEASE,heard);
    >
    > dg.dispatchEvent(
    >
    > new AdvancedDataGridEvent
    > (
    > AdvancedDataGridEvent.HEADER_RELEASE,
    > false,
    > true,
    > 0, // The zero-based index of the column to sort in the
    DataGrid object's
    > columns array.
    > null,
    > 0,
    > null,
    > null,
    > 0
    > )
    >
    > );
    >
    > function heard(e:Event) {
    >
    > trace("I HEAR IT!");
    > trace(e.type);
    >
    > }
    >
    >
    > I set that up on a button so I can dispatch the event
    with a click. Every
    > time I click the button, the header release event
    listener goes off, but
    > the
    > actual advanceddatagrid remains unchanged until I
    actually click on it's
    > header..
    >
    > Any help would be *GREATLY* appreciated... I've been
    stuck on this problem
    > for
    > two days now :(
    Check the compareFunctions here
    http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

  • Data Grid Sort Within Portlet

    I have a portal with a portlet that contains a search form and a data grid. I have set the sortable attribute on the column to true. The sort action gets the filter service and passes it to the DB control.
    I cannot seem to get the sorting to work. The output from getSortFilterService().getDatabaseFilter(getGridName()).getOrderByClause() is always empty no matter which column I click.
    Is there something special I have to do because of the portal/portlet?
    Can someone give me a tip (or two). I realize this is a novice question but I am learning as I go and would appreciate any help.
    Edited by markml at 09/20/2007 9:41 PM

    I figured it was locking up the browser. I submitted a bug ticket several months ago concerning the same issue. If you have "enableviewstate" set to true on a datagrid and you are using the PT web controls, then the browser will lock up. It all depends on the number of rows and columns you have in the datagrid; unfortunately, I don't know the fatal number.
    However, what causes it is how Plumtree manages the viewstate itself for a datagrid. In a nutshell, they have to remember the viewstate for each single item in the grid. And the algorithm they use is extremely slow. The browser's scripting engine basically locks up because of the length of time it takes.
    Unless you absolutely need it, I would just turn off the viewstate. It disables some fancy features of the datagrid, but you can still build workarounds.
    Hope this helps/clarifies things for you!
    --JasonFTN Financial

  • Data Grid Control +JSP+Sorting

    Hi,
    Can any one help me regarding In JSP by using Data Grid Control to sort columns in table and displayed in same JSP.

    Yes! We can help! Do you have any other questions?
    Edited by: SoulTech2012 on Sep 20, 2008 11:51 AM

  • Anyone have a custom "revolving" data grid?

    Rather than the plain scroll-up, scroll-down datagrid, I'm
    looking for one that revolves like the tread of a tank. Kinda like
    each end of the datagrid is attached to a roller and scrolling up
    or down rolls the datagrid out. Just curious if anyone has seen
    different, custom datagrids.

    I've used the distortion effects in a recent project of mine.
    However it's not what I'm looking for. I don't need any state
    changes or transitions. The effect I'm looking for is a conveyor
    belt-type datagrid.
    Imagine a datagrid, but instead of it being confined to a
    window, the top and bottom of the data grid either slightly fade or
    slightly "bend" around the top or bottom.
    Here is my desired "effect" for the datagrid except instead
    of the horizontal rotation of this example, I'd want my datagrid to
    rotate vertically
    http://www.actionscript.org/showMovie.php?id=1284
    As you can see, the ends seem to "bend" as they approach one
    side or another.
    maybe it's just not possible but figured I would ask here
    anyway.

  • Reading a csv file and bind to a data grid

    hi. doing a school project and been searching. the application reads a csv file from c:\stocklist.csv, and then this in a button called btnLoadData, and now need to read in a data control called DmgDisplayData. do i put the code in the button, or in the
    data grid. been searching, but cannot seem to find any thing. so, where do i put the code, in the data control, and does any one have an example code how to read into the data fields. also need to have one field, able to edit, the other three or four fields,
    read only. can any one help me out. never covered this in the subject, but did do file streams a few years ago in vb, but usin g c#,a dn the help in visual studio, not that helpful, with a blind person using a screen reader, jaws for windows from http://www.freedomscientific.com,
    and using visual studio 2013 community edition. can any one help me out, been searching and trawling about 15 to 20 pages so far, and did try a couple of sites, but could not find, any help. thanks. the application is to read a csv file from a button, and
    load into a data grid, then have a message box, saying file load successful, then have one field, order on as edit, but the other fields, read only, so do i need the navigator buttons, for next, back, previous, etc, and how do i code that as well. not to do
    it for me, want to learn, but maybe some sample code, did do navgiator controls, years ago for a vb project, but need the c # example for that, thanks. then you have a button, Save data, that saves the csv file in the data grid. so can google for that. then
    have a toolbar, with a button saying, Sort Items, a tool strip, and when you click on that button, you have a drop down list, of three items, then a sort button, which will then sort the array in the data grid. so, do i need another form, or just do the combo
    box as an invisible control, then just refrence, that in the toolbar. so need to use th file class and an array, learnt about single and multi arrays. any ideas. thanks.
    http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOz

    Hi Marvin,
    -->where do i put this, in the data grid click event. or in the form load event. thanks.
    You could use this code after you initialize the DataGridView. you could put it in the form load event.
    -->what about how get the tool bar and the combo box and another button, then sort from the combo box on the array for the collumns, for to set focus to the first read collumn for the data grid. how do i do that, close the parent form, and have another
    form on the toolbar.
    Since this is another issue of this thread, I would recommend you posting it with
    another thread. We will focus on that thread to help you. Thanks for your
    understanding.
    BTW, Before you asking questions, I suggest you could learn to make it by yourself. You could begin to learn winforms in MSDN articles:
    https://msdn.microsoft.com/en-us/library/dd30h2yb%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396. Or Google it, you will get many answers. In that way, you will learn more from the questions.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Display value in data grid

    08/29/2008 08:58:48 AM
    Reply | Quote | Top | Bottom | Edit
    hi all,
    i have two classes.
    class User
    public String name;
    public int age;
    public Address address;
    class Address
    public String city;
    I'm passing a List<Users> to the data provider of a
    data grid . I can display the values of properties of Users i.e,
    name and age.. My issue is how do i display the value of city which
    is a propertyt of Address class in the datagrid column..
    thanx in advance
    Mark this message as the answer.
    Print this message
    Report this to a Moderator

    Hi,
    Try labelFunction property of the DataGridColumn.
    labelFunction allow you to specify a function name, which will be
    invoked when that data is rendered. You will get the Object (User
    id your case) corresponding the row being rendered will be passed
    as argument to the function. You can use the object and return the
    value you want to be displayed.
    Please find more details on labelFunction at the URL below
    http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridColumn.html#l abelFunction
    You can also try custom item renderer.
    Hope this helps.

  • FillBy always fills in the same row in data grid view. How to make it fill in a new row for each click of the Fillby Button? VB 2010 EXPRESS?

    Hi there, 
    I am a beginner in Visual Basic Express 2010. I have a Point of Sale program that uses DataGridView to display records from an external microsoft access
    database using the fillby query. 
    It works, but it repopulates the same row each time, but i want to be able to display multiple records at the same time, a new row should be filled for
    each click of the fillby button. 
    also I want to be able to delete any records if the customer suddenly decides to not buy an item after it has already been entered. 
    so actually 2 questions here: 
    1. how to populate a new row for each click of the fillby button 
    2. how to delete records from data grid view after an item has been entered 
    Thanks 
    Vishwas

    Hello,
    The FillBy method loads data according to what the results are from the SELECT statement, so if there is one row then you get one row in the DataGridView, have two rows then two rows show up.
    Some examples
    Form load populates our dataset with all data as it was defined with a plain SELECT statement. Button1 loads via a query I created after the fact to filter on a column, the next button adds a new row to the existing data. When adding a new row it is appended
    to the current data displayed and the primary key is a negative value but the new key is shown after pressing the save button on the BindingNavigator or there are other ways to get the new key by manually adding the row to the backend table bypassing the Adapter.
    The following article with code shows this but does not address adapters.
    Conceptually speaking the code in the second code block shows how to get the new key
    Public Class Form1
    Private Sub StudentsBindingNavigatorSaveItem_Click(
    sender As Object, e As EventArgs) Handles StudentsBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.StudentsBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'MyDataSet.Students' table. You can move, or remove it, as needed.
    Me.StudentsTableAdapter.Fill(Me.MyDataSet.Students)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.StudentsTableAdapter.FillBy(Me.MyDataSet.Students, ComboBox1.Text)
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Me.MyDataSet.Students.AddStudentsRow("Jane", "Adams", "Female")
    End Sub
    End Class
    Get new key taken from
    this article.
    Public Function AddNewRow(ByVal sender As Customer, ByRef Identfier As Integer) As Boolean
    Dim Success As Boolean = True
    Try
    Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
    Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
    cmd.CommandText = InsertStatement
    cmd.Parameters.AddWithValue("@CompanyName", sender.CompanyName)
    cmd.Parameters.AddWithValue("@ContactName", sender.ContactName)
    cmd.Parameters.AddWithValue("@ContactTitle", sender.ContactTitle)
    cn.Open()
    cmd.ExecuteNonQuery()
    cmd.CommandText = "Select @@Identity"
    Identfier = CInt(cmd.ExecuteScalar)
    End Using
    End Using
    Catch ex As Exception
    Success = False
    End Try
    Return Success
    End Function
    In closing I have not given you a solution but hopefully given you some stuff/logic to assist with this issue, if not perhaps I missed what you want conceptually speaking.
    Additional resources
    http://msdn.microsoft.com/en-us/library/fxsa23t6.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • How to specifically sort the data in a database using c#?

    H!,
    I have a problem in c# that require sorting of names of students in a sql database and i want it to be specific, i used data grid view to view the data of the students as shown below:
    Students First Name:
    Ann
    Antoinette
    Brenda
    Judith
    Lester
    Santos
    Suzie
    Tim
    if i type in a letter or abbreviation @ a textbox1 for example "s", all Names that starts with letter s will be sorted first so the output now of the query will become:
    Students First Name:
    Santos
    Suzie
    Ann
    Antoinette
    Brenda
    Judith
    Lester
    Tim
    So if i type j, all that starts with j will be first, and so on.
    I need help for this problem coz it is so hard for me to output the students with this kind of sorting and is there a code or query string related to this problem?
    thanks in advance.
    Hardz

    Hi,
    One way is to write a query as shown below:
    declare @char nvarchar(1)
    select @char = 'S'
    Declare @t table(name nvarchar(max))
    insert into @t
    values
    ('Santos'),
    ('Suzie'),
    ('Ann'),
    ('Antoinette'),
    ('Brenda'),
    ('Judith'),
    ('Lester'),
    ('Tim')
    select name
    from @t
    where RIGHT(name,1) like @char
    union all
    select name
    from
    (select top 100 percent name
    from @t
    where RIGHT(name,1) not like @char
    order by name) a
    Hope this helps. 
    -Chintak

Maybe you are looking for

  • How do I save multiple backups for one device in iTunes?

    Hey, I manage multiple iPads here at my school and had a question about iTunes backup. We want to have multiple backups from the past for each device so that we can restore the device from an old backup if something goes wrong. We have over 180 iPads

  • Mid 2009 applecare logic board and battery ADVICE

    returning mac OS and mac hardware buyer here. i have been questioning (read complaining) about the battery life (1 1/2 hours on safari) and the performance (spinning beachballs on startup, on wake and on starting safari among other things) since i bo

  • Need new all-in-one printer compatible w/Mountain Lion

    I upgraded my MBP to Mountain Lion a few months ago, and I'm having a printer crisis.  I have a Canon MP500 which does a very nice job printing photos, documents and copying, but the scanning feature won't work with Mountain Lion. I contacted Canon a

  • TV Episodes Appearing Under Movies

    Ever since I upgraded to Snow Leopard, TV episodes I've ripped from DVDs I own that I add to iTunes have been appearing in the movies category of Front Row. It is driving me bananas, because I have a lot of media in my library, and I enjoyed accessin

  • Reducing Slide Size without scaling objects

    Hi All, I have a presentation that is in 2 sizes 1920X1220 and 1920X1080. If we increase the custom size of a slide show it does not resize the type and content. If we try to decrease the size it resizes the type and content. Unfortunately we started