I have binded a data grid to an array. Also, there is a button there to delete the row. The problem is that I am not sure how to implement it since the data source is an array.
See below
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID="lblItems" runat="server" Text='<%# Container.DataItem>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" Text="Delete">
</asp:ButtonColumn>
</Columns>
and here I would like to implement it..
private void DataGrid1_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int rowToDelete = e.Item.ItemIndex;
myDataGrid.DataBind();
}
In the code for the deletion, how can I access the index of my array based on the button clicked (per row)?
Here is an example
Markup.
Code-behind.
Hope this helps.