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
 Datagrid Edit, Cancel, Paging calls SortCommand...

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2008-12-04 : 15:09:17
My issue is I'm trying to have a datagrid (ASP.NET 1.1) to allow editing, along with sorting ASC/DESC via column headers.

When I click "Edit", my SQL query ASC goes to DESC, and vice versa. This happens on Cancel, Paging, Delete, etc...I'm trying to limit the "swap" in the order by criterion only when a header (of Template columns) is clicked.

****************I have this in the HTML:

OnSortCommand="SortDG" AllowSorting="True"

***************Code behind to try to limit only to column headers, but not working:

Private Sub DGActivities_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DGActivities.ItemCommand

If e.Item.ItemType = ListItemType.Header Then

If ViewState("DGActGlobalAscDesc") = "" Then

ViewState("DGActGlobalAscDesc") = "ASC"

SwapDirection(ViewState("DGActGlobalAscDesc"))

Else

SwapDirection(ViewState("DGActGlobalAscDesc"))

End If

End If

End Sub



Sub SwapDirection(ByVal viewStateKey As String)

If ViewState(viewStateKey) = "ASC" Then

ViewState(viewStateKey) = "DESC"

ViewState("DGActFieldAscDesc") = "DESC"

Else

ViewState(viewStateKey) = "ASC"

ViewState("DGActFieldAscDesc") = "ASC"

End If

End Sub
   

- Advertisement -