Problem with Sorting datagrid .. help please

B

Burak

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top