Solved
manually sorting a datagrid containing an asp:ButtonColumn?
Posted on 2006-07-08
I need to sort a datagrid manually (can't just requery and change the ORDER BY clause). The code below works perfectly for every column except the asp:ButtonColumn. How to swap the two button controls?
'test code to swap row 1 and row 2
Dim i As Integer
For i = 0 To dg.Columns.Count - 1
Dim s As String = dg.Items(1).Cells(i).Text
dg.Items(1).Cells(i).Text = dg.Items(2).Cells(i).Text
dg.Items(2).Cells(i).Text = s
Next
From the .aspx for the button controls:
<asp:ButtonColumn ButtonType="PushButton" DataTextField="job_number" SortExpression="job_number"
HeaderText="Job" CommandName="Select" DataTextFormatString="{0}"></asp:ButtonColumn>
Thanks for any help-