Return GridView sort to default

D

David C

I have an asp GridView that has the SqlDataSource below.

<asp:SqlDataSource ID="SqlvwRepairOrdersOpen" runat="server"
ConnectionString="<%$ ConnectionStrings:MgmtConnectionString %>"
SelectCommand="SELECT [RecordID], [RepairOrderID], [Problems],
[TasksToDo], [Customer], [Vehicle], [Expected], [ROTotal], [JobSize],
[PartsCount], [Payor], [SortGroup], [Parts], [InsuranceID] FROM
[vw_RepairOrdersOpen] ORDER BY [SortGroup], [RepairOrderID] DESC">
</asp:SqlDataSource>

I also have a CheckBox control with ID of ckNormalSort and when it is
checked, I want the GridView to go back to the initial sort from the
SqlDataSource. I have tried the code below in both Page_Load and in the
CheckChanged event of the checkbox and neither works. How can this be
accomplished? Thanks.

David


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If ckNormalSort.Checked = True Then
SqlvwRepairOrdersOpen.SelectCommand = "SELECT [RecordID],
[RepairOrderID], [Problems], [TasksToDo], [Customer], [Vehicle], [Expected],
[ROTotal], [JobSize], [PartsCount], [Payor], [SortGroup], [Parts],
[InsuranceID] FROM [vw_RepairOrdersOpen] ORDER BY [SortGroup],
[RepairOrderID] DESC"
SqlvwRepairOrdersOpen.DataBind()
End If
End Sub
 
M

miher

David C said:
I have an asp GridView that has the SqlDataSource below.

<asp:SqlDataSource ID="SqlvwRepairOrdersOpen" runat="server"
ConnectionString="<%$ ConnectionStrings:MgmtConnectionString %>"
SelectCommand="SELECT [RecordID], [RepairOrderID], [Problems],
[TasksToDo], [Customer], [Vehicle], [Expected], [ROTotal], [JobSize],
[PartsCount], [Payor], [SortGroup], [Parts], [InsuranceID] FROM
[vw_RepairOrdersOpen] ORDER BY [SortGroup], [RepairOrderID] DESC">
</asp:SqlDataSource>

I also have a CheckBox control with ID of ckNormalSort and when it is
checked, I want the GridView to go back to the initial sort from the
SqlDataSource. I have tried the code below in both Page_Load and in the
CheckChanged event of the checkbox and neither works. How can this be
accomplished? Thanks.

David


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If ckNormalSort.Checked = True Then
SqlvwRepairOrdersOpen.SelectCommand = "SELECT [RecordID],
[RepairOrderID], [Problems], [TasksToDo], [Customer], [Vehicle],
[Expected], [ROTotal], [JobSize], [PartsCount], [Payor], [SortGroup],
[Parts], [InsuranceID] FROM [vw_RepairOrdersOpen] ORDER BY [SortGroup],
[RepairOrderID] DESC"
SqlvwRepairOrdersOpen.DataBind()
End If
End Sub

Hi,
I hope i got Your problem right: You have a sortable gridview and You want
to reset the sorting.
In that case You can simply reset the SortExpression of the gridview, just
by calling the Sort method of it with string.Empty.
Hope You find this useful.
-Zsolt
 
D

David C

miher said:
David C said:
I have an asp GridView that has the SqlDataSource below.

<asp:SqlDataSource ID="SqlvwRepairOrdersOpen" runat="server"
ConnectionString="<%$ ConnectionStrings:MgmtConnectionString %>"
SelectCommand="SELECT [RecordID], [RepairOrderID], [Problems],
[TasksToDo], [Customer], [Vehicle], [Expected], [ROTotal], [JobSize],
[PartsCount], [Payor], [SortGroup], [Parts], [InsuranceID] FROM
[vw_RepairOrdersOpen] ORDER BY [SortGroup], [RepairOrderID] DESC">
</asp:SqlDataSource>

I also have a CheckBox control with ID of ckNormalSort and when it is
checked, I want the GridView to go back to the initial sort from the
SqlDataSource. I have tried the code below in both Page_Load and in the
CheckChanged event of the checkbox and neither works. How can this be
accomplished? Thanks.

David


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If ckNormalSort.Checked = True Then
SqlvwRepairOrdersOpen.SelectCommand = "SELECT [RecordID],
[RepairOrderID], [Problems], [TasksToDo], [Customer], [Vehicle],
[Expected], [ROTotal], [JobSize], [PartsCount], [Payor], [SortGroup],
[Parts], [InsuranceID] FROM [vw_RepairOrdersOpen] ORDER BY [SortGroup],
[RepairOrderID] DESC"
SqlvwRepairOrdersOpen.DataBind()
End If
End Sub

Hi,
I hope i got Your problem right: You have a sortable gridview and You
want to reset the sorting.
In that case You can simply reset the SortExpression of the gridview, just
by calling the Sort method of it with string.Empty.
Hope You find this useful.
-Zsolt

That was it. Thank you.

David
 

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

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top