jump to navigation

Dynamic Button Columns September 29 2004

Suppose as you generate a datagrid that you want a button associated with each row. This will demonstrate how to create the dynamic row along with retrieving the item index (e.g. Primary key)

Step 1: Create the data grid

<asp:datagrid runat=”server” id=”dgMyDG” DataKeyField=”row_id” OnItemCommand=”dgMyDG_ItemCommand”>
<Columns>
<ButtonColumn Text=” [ delete ] ” CommandName=”delete_row” />

</Columns>
</asp:datagrid>

Step 2: Create the receiving Command

Sub dgMyDG(byval s as object, byval e as DataGridCommandEventArgs)

dim selected_row_id = dgMyDG.DataKeys(e.item.itemIndex)

End Sub

Comments»

no comments yet - be the first?