I have a LinkButton within a Datagrid. I am having trouble setting a Click event for it. I will add the OnClick="Remove_Click" attribute in the HTML. But when I go to write the actual event, VB isn't finding the LinkButton. Therefore nothing happens.
Here is the code for it.
<asp:DataGrid ID="StandardsDataGrid" runat="server" ShowHeader="false"
ShowFooter="false"
AutoGenerateColumns="false" CellPadding="2" CellSpacing="0"
ItemStyle-VerticalAlign="middle"
DataKeyField="Id" Width="100%" BorderColor="#000">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="Remove" OnClick="Removed_Click" runat="server"
Text="<img src='../images/btnDelete.gif' border='0'>" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Any ideas on why VB isn't recognizing it? Or is there a different way I should go about performing a click event?
Check this out, took me excactly one second to find it!
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemtemplate.aspx
You have to use
and handle the Command Event of the grid
this is a common usage:
And here how you can handle it