I have a DataGrid that I want to sort when a ImageButton in the column header is clicked. The column appears perfectly along with the ImageButton:
On the backend, I have the following event handler code:
I placed a breakpoint in my event handler code and found that clicking the ImageButton does not cause the event to fire. If I replace the ImageButton with a LinkButton with the same CommandName arguement, the event is fired and the breakpoint is reached:
Did I miss a step? All the docs I've read at MSDN and VB.Net Help indicate to do it as shown above.
Thanks!
PHP:
<asp:TemplateColumn SortExpression="Fullname DESC">
<HeaderStyle Width="25%" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle Width="25%"></ItemStyle>
<HeaderTemplate>
<nobr>Full Name
<asp:ImageButton id="btnSortFullname" runat="server" CommandName="sort" ImageUrl="images/sort.png"
Width="28" Height="15" CommandArgument="Fullname DESC" ImageAlign="AbsMiddle" />
</nobr>
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Fullname") %>
</ItemTemplate>
</asp:TemplateColumn>
On the backend, I have the following event handler code:
PHP:
Private Sub DataGrid1_SortCommand(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand
SortField = e.SortExpression
BindDataGrid()
End Sub
I placed a breakpoint in my event handler code and found that clicking the ImageButton does not cause the event to fire. If I replace the ImageButton with a LinkButton with the same CommandName arguement, the event is fired and the breakpoint is reached:
PHP:
<asp:LinkButton runat="server" CommandName="sort" CommandArgument="Fullname DESC" ID="Linkbutton1">My LinkButton</asp:LinkButton>
Did I miss a step? All the docs I've read at MSDN and VB.Net Help indicate to do it as shown above.
Thanks!