Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Is this possible?

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-01-22 : 09:28:43
I have a Gridview on the page with sorting enabled

Oct08 Nov08 Dec08 Jan09
NAT 12.0 14.7 14.2 14.1
PHL 13.7 15.5 13.9 14.0
01 12.8 14.3 12.5 14.1
200 15.8 12.1 9.4 9.9


I don't want NAT and PHIL to be included in the sort so when I click on Jan09 value 9.9 should be first then 14.1 should be second. If I click Jan09 again it should go back to the way it is above. What I want to do is freeze/exclude rows NAT and PHIL out of the sorting. Looked everywhere and can't find how to do this. Is this possible?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-22 : 09:44:21
In T-SQL the query would look something similar to this
ORDER BY ISNUMERIC(Column) DESC, Value DESC

Do your own sorting mechanism for the GRID and sort by ascending row header if numeric or not, and then current column value


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-01-22 : 10:13:39
I'm sorry I don't know what you mean by sorting by row header and then by value.

Here's my gridview:

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlNatPct" CssClass="detailsView" Caption="Trend-Last 13 months of data" AllowSorting="True">
<SelectedRowStyle BorderColor="White" BorderStyle="Dashed" />
<HeaderStyle BackColor="Navy" ForeColor="White" />
<AlternatingRowStyle BackColor="Linen" />
<EditRowStyle ForeColor="Navy" />
</asp:GridView>
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-01-23 : 06:15:39
You can write some logic in datagrid sort command to prevent the the rows containing nat & phl.Maybe write a rowfilter method for the datatable to prevent the rows u dont need.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-01-26 : 10:59:19
Okay I've tried this but it is still not working any ideas?

Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As
GridViewSortEventArgs)


If e.SortExpression = "sort" Then
' original columnname
e.SortExpression = "Reg"
End If
' New field for sorting
GridView1.DataBind()


End Sub


It's still sorting by the 2nd column


Here's my table. When I click on Dec08 it goes in order then when I
click on Reg I want it to go back into Sort field order but it
doesn't.


Sort Reg Dec08 Jan09
1 NAT 12.4 15.8
A BOS 22.2 23.0
B NYC 25.9 16.0
C PHL 12.3 33.3
D ATL 14.4 23.3


Go to Top of Page
   

- Advertisement -