Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Problem with Sorting datagrid .. help please

Reply
Thread Tools

Problem with Sorting datagrid .. help please

 
 
Burak
Guest
Posts: n/a
 
      05-13-2004
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.DataGridSortCommandEvent Args) 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
 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      05-13-2004
Burak, see:
http://aspnet.4guysfromrolla.com/articles/012903-1.aspx

Also, I discuss this in Chapter 7 of my book, ASP.NET Data Web Controls
Kick Start
[http://www.amazon.com/exec/obidos/AS...ysfromrollaco]

Happy Programming!

--

Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
 
Saravana [MVP]
Guest
Posts: n/a
 
      05-14-2004
Check out this article,
http://www.dotnetbips.com/displayarticle.aspx?id=7

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



"Burak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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.DataGridSortCommandEvent Args) 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
fired event Sorting which wasn't handled - sorting and SelectedIndexChanged Jason ASP .Net Web Controls 0 10-04-2006 02:19 PM
[Datagrid,web form]: How the get the correct row values after sorting datagrid by header AlainCD ASP .Net Datagrid Control 0 01-12-2006 09:07 AM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments