Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default datagrid won't sort

    I have a datagrid that won't sort. The event handler is firing and return
    label text, just not the sort.

    Here's my Sub Page_Load and Sub DataGrid1_SortCommand:

    --------------------

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    SqlDataAdapter1.Fill(DsAdvanced1)

    If Not IsPostBack Then
    DataGrid1.DataBind()
    Provinces.DataBind()
    Districts.DataBind()
    SubDistricts.DataBind()
    Communities.DataBind()
    End If

    End Sub

    --------------------


    Public Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
    DataGrid1.SortCommand

    lblWhatClicked.Text = "You clicked: " & e.SortExpression

    Dim dv As New DataView(DsAdvanced1.Tables(0))
    dv.Sort = e.SortExpression
    DataGrid1.DataSource = dv
    DataGrid1.DataBind()

    End Sub

    --
    _____
    DC G


    DC Gringo Guest

  2. Similar Questions and Discussions

    1. sort in datagrid
      Hi, I have some columns in my datagrid which are date type. I want to sort on them. What would be the best way to do it. Based on a article to...
    2. Sort datagrid
      Hello Group, I have a datagrid which needs to be sorted but the column headers should not be clickable on certain conditions( say on the "print...
    3. Datagrid sort
      I have a datagrid that sorts. The sort doesn't seem to execute on my template column. It only works on my bound columns.
    4. bidirectional sort with datagrid
      Can someone show me how to turn this into a bi-directional sort allowing ascending and descending using the default datagrid allowsorting attribute?...
    5. Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB.
      Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp...
  3. #2

    Default Re: datagrid won't sort

    Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    [url]http://tinyurl.com/3he3b[/url]
    "DC Gringo" <dcgringo@visiontechnology.net> wrote in message
    news:OaAMDdu$DHA.2012@TK2MSFTNGP11.phx.gbl...
    > I have a datagrid that won't sort. The event handler is firing and return
    > label text, just not the sort.
    >
    > Here's my Sub Page_Load and Sub DataGrid1_SortCommand:
    >
    > --------------------
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    > SqlDataAdapter1.Fill(DsAdvanced1)
    >
    > If Not IsPostBack Then
    > DataGrid1.DataBind()
    > Provinces.DataBind()
    > Districts.DataBind()
    > SubDistricts.DataBind()
    > Communities.DataBind()
    > End If
    >
    > End Sub
    >
    > --------------------
    >
    >
    > Public Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
    > DataGrid1.SortCommand
    >
    > lblWhatClicked.Text = "You clicked: " & e.SortExpression
    >
    > Dim dv As New DataView(DsAdvanced1.Tables(0))
    > dv.Sort = e.SortExpression
    > DataGrid1.DataSource = dv
    > DataGrid1.DataBind()
    >
    > End Sub
    >
    > --
    > _____
    > DC G
    >
    >

    Alvin Bruney [MVP] Guest

  4. #3

    Default Re: datagrid won't sort

    Sort of...thankfully I'm only in beta and I got it to work without using
    code-behind...I must have issues relating to the sharing of variables
    between the separate pages...



    -____-
    DG


    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:ORt2zcGAEHA.2484@TK2MSFTNGP12.phx.gbl...
    > Your post went unanswered. Have you resolved this issue?
    >
    > --
    > Regards,
    > Alvin Bruney [ASP.NET MVP]
    > Got tidbits? Get it here...
    > [url]http://tinyurl.com/3he3b[/url]
    > "DC Gringo" <dcgringo@visiontechnology.net> wrote in message
    > news:OaAMDdu$DHA.2012@TK2MSFTNGP11.phx.gbl...
    > > I have a datagrid that won't sort. The event handler is firing and
    return
    > > label text, just not the sort.
    > >
    > > Here's my Sub Page_Load and Sub DataGrid1_SortCommand:
    > >
    > > --------------------
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > > SqlDataAdapter1.Fill(DsAdvanced1)
    > >
    > > If Not IsPostBack Then
    > > DataGrid1.DataBind()
    > > Provinces.DataBind()
    > > Districts.DataBind()
    > > SubDistricts.DataBind()
    > > Communities.DataBind()
    > > End If
    > >
    > > End Sub
    > >
    > > --------------------
    > >
    > >
    > > Public Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
    > > DataGrid1.SortCommand
    > >
    > > lblWhatClicked.Text = "You clicked: " & e.SortExpression
    > >
    > > Dim dv As New DataView(DsAdvanced1.Tables(0))
    > > dv.Sort = e.SortExpression
    > > DataGrid1.DataSource = dv
    > > DataGrid1.DataBind()
    > >
    > > End Sub
    > >
    > > --
    > > _____
    > > DC G
    > >
    > >
    >
    >

    DC Gringo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139