Grid View
In aspx's HTML:
asp:GridView AutoGenerateColumns="False" + ShowFooter
Columns
asp:TemplateField with HeaderText for each field
- ItemTemplate with asp:Label to define each field
- FooterTemplate with asp:TextBox to define each field
asp:TemplateField with HeaderText for Action
-ItemTemplate
--- asp:LinkButton for Delete OnClientClick and OnClick
--- asp:LinkButton for Edit with OnClick
-FooterTemplate
--- asp:LinkButton for Add with OnClick
In C#:
GridView1.DataSource and DataBind
OnDelete(sender,args)
LinkButton item = sender as LinkButton;
GridViewRow row = btn.NamingContainer as GridViewRow;
string productID = (row.FindControl("gridviewProductID") as Label).Text;
var idx = products.FindIndex(x => x.ProductID.Equals(productId.Trim()));
products.RemoveAt(idx);
GridView1.DataSource = null;
GridView1.DataSource = products;
GridView1.DataBind();
ResultLabel.Text = productID + " was deleted";