Hello,
I have a datagrid as follows
<asp:datagrid id="dtgIncomplete" Runat="server" OnPageIndexChanged="PageActiveRecords" AllowPaging="True" PageSize="25" autogeneratecolumns="false" Width="537px" AllowSorting="True" OnSortCommand="SortCommand_OnClick">
<Columns>
<asp:BoundColumn HeaderText="VJC Ref#" SortExpression="JOB_ID" DataField="JOB_ID" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></asp:BoundColumn>
<asp:BoundColumn HeaderText="Company Job ID" SortExpression="EMPLOYERS_JOB_ID" DataField="EMPLOYERS_JOB_ID" HeaderStyle-HorizontalAlign="Center"
etc..
</Columns>
</asp:datagrid>
and here is my sort function
Sub SortCommand_OnClick(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dtgIncomplete.SortCommand
GetActiveJobs(dtgIncomplete.CurrentPageIndex, e.SortExpression)
End Sub
Sub GetActiveJobs(ByVal index As Integer, Optional ByVal strSort As String = "")
Dim Source As DataView = ds.Tables(0).DefaultView
If strSort = "" Then
Source.Sort = "job_id"
Else
Source.Sort = strSort
End If
'bind the data source
dtgIncomplete.DataSource = Source
dtgIncomplete.CurrentPageIndex = index
dtgIncomplete.PageSize = lstDisplay.SelectedValue
dtgIncomplete.DataBind()
End Sub
When I click on the header columns in the datagrid, it only does an ascending sort.
How can I have it do both ascending and descending?
Thank you,
Burak
I have a datagrid as follows
<asp:datagrid id="dtgIncomplete" Runat="server" OnPageIndexChanged="PageActiveRecords" AllowPaging="True" PageSize="25" autogeneratecolumns="false" Width="537px" AllowSorting="True" OnSortCommand="SortCommand_OnClick">
<Columns>
<asp:BoundColumn HeaderText="VJC Ref#" SortExpression="JOB_ID" DataField="JOB_ID" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></asp:BoundColumn>
<asp:BoundColumn HeaderText="Company Job ID" SortExpression="EMPLOYERS_JOB_ID" DataField="EMPLOYERS_JOB_ID" HeaderStyle-HorizontalAlign="Center"
etc..
</Columns>
</asp:datagrid>
and here is my sort function
Sub SortCommand_OnClick(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dtgIncomplete.SortCommand
GetActiveJobs(dtgIncomplete.CurrentPageIndex, e.SortExpression)
End Sub
Sub GetActiveJobs(ByVal index As Integer, Optional ByVal strSort As String = "")
Dim Source As DataView = ds.Tables(0).DefaultView
If strSort = "" Then
Source.Sort = "job_id"
Else
Source.Sort = strSort
End If
'bind the data source
dtgIncomplete.DataSource = Source
dtgIncomplete.CurrentPageIndex = index
dtgIncomplete.PageSize = lstDisplay.SelectedValue
dtgIncomplete.DataBind()
End Sub
When I click on the header columns in the datagrid, it only does an ascending sort.
How can I have it do both ascending and descending?
Thank you,
Burak