i have one gridview the value coming from textbox when the button click then value save in gridView , i want to add the button which remove and update the row in gridView .how do i can do this .the code of gridview is below
//this button add the grid view on button click of product details
protected void btnSubmit0_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Product");
dt.Columns.Add("Product Name");
dt.Columns.Add("Qunatity");
dt.Columns.Add("UnitPrice");
dt.Columns.Add("total");
DataRow dr = null;
if (ViewState["sale"] != null)
{
for (int i = 0; i < 1; i++)
{
dt = (DataTable)ViewState["sale"];
if (dt.Rows.Count > 0)
{
dr = dt.NewRow();
dr["Product"] = ddlProduct.SelectedValue;
dr["Product Name"] = ddlProduct.SelectedItem.Text;
dr["Qunatity"] = Convert.ToInt32(txtQuantity.Text);
dr["UnitPrice"] = Convert.ToInt32(TxtUnitPrice.Text);
dr["total"] = Convert.ToInt32(TxtTotal.Text);
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
else
{
dr = dt.NewRow();
dr["Product"] = Convert.ToInt32(ddlProduct.SelectedValue);
dr["Product Name"] = ddlProduct.SelectedItem.Text;
dr["Qunatity"] = Convert.ToInt32(txtQuantity.Text);
dr["UnitPrice"] = Convert.ToInt32(TxtUnitPrice.Text);
dr["total"] = Convert.ToInt32(TxtTotal.Text);
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
}
ViewState["sale"] = dt;
lblItemAdd.Text = "item add in list";
txtQuantity.Text = "";
TxtUnitPrice.Text = "";
TxtTotal.Text = "";
}