Sorting a dataview

Discussion in 'ASP .Net' started by =?Utf-8?B?U3VuZWV0?=, Aug 10, 2004.

  1. Hello,

    I am trying to sort the values of a dataset based on the column the user
    selects on the web page, how the code below does not sort. I have hard coded
    a column for now, but any suggestions would be appreciated.

    Dim comInvView As DataView 'Community Inventory View

    'Put user code to initialize the page here
    Dim objCommunityInventory As DataSet
    Dim aSqlParameter(2) As SqlClient.SqlParameter
    aSqlParameter(0) = GetSqlParameter("@DivisionID",
    Request.QueryString("DivisionID"), SqlDbType.Int)
    aSqlParameter(1) = GetSqlParameter("@CommunityID",
    Request.QueryString("CommunityID"), SqlDbType.Int)
    aSqlParameter(2) = GetSqlParameter("@PhaseID",
    IIf(Request.QueryString("PhaseID").ToString = "0", DBNull.Value,
    Request.QueryString("PhaseID")), SqlDbType.Int)
    objCommunityInventory = New DataSet()
    lblDate.Text = Now.ToString

    FillDataSet("rptCommunityInventory", aSqlParameter,
    CType(objCommunityInventory, Object), "CommunityInventory")

    objCommunityInventory.Tables(0).Columns.Remove("Title")
    objCommunityInventory.AcceptChanges()


    comInvView =
    objCommunityInventory.Tables("CommunityInventory").DefaultView()
    comInvView.Sort = "Status DESC"
    dgCommunityInventory.DataSource = comInvView
    dgCommunityInventory.DataBind()


    Thanks
    Suneet
    =?Utf-8?B?U3VuZWV0?=, Aug 10, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?U3VuZWV0?=

    Duron Guest

    How if

    Dim dt As DataTable
    dt = objCommunityInventory.Tables("CommunityInventory")
    dt.DefaultView.Sort = "Status DESC"
    dgCommunityInventory.DataSource = dt.DefaultView
    dgCommunityInventory.DataBind()

    -Duron

    "Suneet" <> ¼¶¼g©ó¶l¥ó·s»D
    :...
    > Hello,
    >
    > I am trying to sort the values of a dataset based on the column the user
    > selects on the web page, how the code below does not sort. I have hard

    coded
    > a column for now, but any suggestions would be appreciated.
    >
    > Dim comInvView As DataView 'Community Inventory View
    >
    > 'Put user code to initialize the page here
    > Dim objCommunityInventory As DataSet
    > Dim aSqlParameter(2) As SqlClient.SqlParameter
    > aSqlParameter(0) = GetSqlParameter("@DivisionID",
    > Request.QueryString("DivisionID"), SqlDbType.Int)
    > aSqlParameter(1) = GetSqlParameter("@CommunityID",
    > Request.QueryString("CommunityID"), SqlDbType.Int)
    > aSqlParameter(2) = GetSqlParameter("@PhaseID",
    > IIf(Request.QueryString("PhaseID").ToString = "0", DBNull.Value,
    > Request.QueryString("PhaseID")), SqlDbType.Int)
    > objCommunityInventory = New DataSet()
    > lblDate.Text = Now.ToString
    >
    > FillDataSet("rptCommunityInventory", aSqlParameter,
    > CType(objCommunityInventory, Object), "CommunityInventory")
    >
    > objCommunityInventory.Tables(0).Columns.Remove("Title")
    > objCommunityInventory.AcceptChanges()
    >
    >
    > comInvView =
    > objCommunityInventory.Tables("CommunityInventory").DefaultView()
    > comInvView.Sort = "Status DESC"
    > dgCommunityInventory.DataSource = comInvView
    > dgCommunityInventory.DataBind()
    >
    >
    > Thanks
    > Suneet
    Duron, Aug 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Saunders

    Re: alpha numeric sorting for dataview

    John Saunders, Jul 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,677
    John Saunders
    Jul 20, 2004
  2. Jason

    dataview sorting in manual order?

    Jason, Sep 1, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    4,384
    Jason
    Sep 2, 2004
  3. =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=

    DataView data accessor aware of sorting used

    =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    373
    =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=
    Nov 22, 2004
  4. Patrick Olurotimi Ige

    DataView Sorting with Paging Question

    Patrick Olurotimi Ige, Dec 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,981
    Patrick Olurotimi Ige
    Dec 9, 2004
  5. CodeMonkey
    Replies:
    1
    Views:
    719
    joyal jhaveri
    Feb 4, 2011
Loading...

Share This Page