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.
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.