SortExression is not updated

V

Vishal

Hello,

I have build my own datagrid control extended from the
normal datagrid. This datagrid has autogenerate columns
set to false. I am adding the columns manually based on
the dataset. Now the problem is when I do a sort in my
webform where I am using this component, then it doesnt
keep the sortexpression. It works when I use it with a
normal datagrid, however it doesnt when I use my own
component. The columns are manually added in Init. However
if the columns count is greater then 0 then I dont add the
columns again. Here is my sorting code:

Dim oCol As DataGridColumn
For Each oCol In AADataGridStores.Columns
' Find the right column
If e.SortExpression.ToLower().CompareTo
(oCol.SortExpression.ToLower()) = 0 Then
oCol.HeaderText = oCol.HeaderText.Replace("
(ASC)", "").Replace(" (DESC)", "")
If e.SortExpression.IndexOf(" ASC") > 1 Then
oCol.SortExpression = e.SortExpression.Replace("
ASC", " DESC")
oCol.HeaderText = oCol.HeaderText + " (DESC)"
ViewState
("SortInvoiceExpressionForStores") = oCol.SortExpression
ElseIf e.SortExpression.IndexOf(" DESC") > 1 Then
oCol.SortExpression = e.SortExpression.Replace("
DESC", "")
ViewState("SortInvoiceExpressionForStores") =
oCol.SortExpression
Else
oCol.SortExpression = e.SortExpression + " ASC"
oCol.HeaderText = oCol.HeaderText + " (ASC)"
ViewState("SortInvoiceExpressionForStores") =
oCol.SortExpression
End If
Exit For
End If
Next

Any help/suggestion is appreciated.
 

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,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top