TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Imran Bashir
NA
186
13.7k
how to Delete and update the Row In gridView
May 23 2016 12:20 PM
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 = "";
}
Reply
Answers (
2
)
How to add Custom Control in asp.net
How can i Delimite and Group Json value on asp.net