J
jobs
The Grid displays with multiple rows. I select a column to sort of a
particular field and the below event is fired, but DataTable is Null so
code is skipped.
The GridView:
<asp:GridView ID="ChargeGridView" runat="server"
AutoGenerateColumns="False" DataKeyNames="RouteCode"
Width="700px" SkinID="GridView"
AllowPaging="True" AllowSorting="true"
OnSorting="ChargeGridView_Sorting" ShowFooter="true"
PagerSettings-Mode="NumericFirstLast">
Protected Sub ChargeGridView_Sorting(ByVal sender As Object, ByVal e
As GridViewSortEventArgs)
Dim dataTable As DataTable = CType(ChargeGridView.DataSource,
DataTable)
If Not (dataTable Is Nothing) Then '****** (THIS IS ALWAYS
FALSE) ****
Dim dataView As DataView = New DataView(dataTable)
dataView.Sort = e.SortExpression + " " + e.SortDirection
Response.Write(e.SortExpression + " " + e.SortDirection)
ChargeGridView.DataSource = dataView
ChargeGridView.DataBind()
End If
End Sub
Thanks.
particular field and the below event is fired, but DataTable is Null so
code is skipped.
The GridView:
<asp:GridView ID="ChargeGridView" runat="server"
AutoGenerateColumns="False" DataKeyNames="RouteCode"
Width="700px" SkinID="GridView"
AllowPaging="True" AllowSorting="true"
OnSorting="ChargeGridView_Sorting" ShowFooter="true"
PagerSettings-Mode="NumericFirstLast">
Protected Sub ChargeGridView_Sorting(ByVal sender As Object, ByVal e
As GridViewSortEventArgs)
Dim dataTable As DataTable = CType(ChargeGridView.DataSource,
DataTable)
If Not (dataTable Is Nothing) Then '****** (THIS IS ALWAYS
FALSE) ****
Dim dataView As DataView = New DataView(dataTable)
dataView.Sort = e.SortExpression + " " + e.SortDirection
Response.Write(e.SortExpression + " " + e.SortDirection)
ChargeGridView.DataSource = dataView
ChargeGridView.DataBind()
End If
End Sub
Thanks.