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
Vignesh Kumar
NA
1k
415.9k
Bulk Update in Grid
Nov 13 2013 5:48 AM
Hi All,
I have a grid where I use a checkbox for bulk update by selecting multiple rows. Now I placed a footer template with the textbox below the grid. Assume like I select two rows in the grid(using checkbox) and when I enter values in the textbox in footertemplate below the grid, then changes have to be reflected to the selected rows in the grid for the columns(Saved to the DB). I use the below update query to update selected checkbox rows to DB and how can I do that to my footertemplate rows which has textbox for update. Any suggestions pls?
protected void Save(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
bool isChecked = row.Cells[0].Controls.OfType<CheckBox>().FirstOrDefault().Checked;
if (isChecked)
{
SqlCommand cmd = new SqlCommand("UPDATE AppInvent_Test SET Name = @Name, Designation = @Designation, City = @City WHERE EmpID = @EmpID");
cmd.Parameters.AddWithValue("@EmpID", row.Cells[1].Controls.OfType<TextBox>().FirstOrDefault().Text);
cmd.Parameters.AddWithValue("@Name", row.Cells[2].Controls.OfType<TextBox>().FirstOrDefault().Text);
cmd.Parameters.AddWithValue("@Designation", row.Cells[3].Controls.OfType<TextBox>().FirstOrDefault().Text);
cmd.Parameters.AddWithValue("@City", row.Cells[4].Controls.OfType<TextBox>().FirstOrDefault().Text);
this.ExecuteQuery(cmd, "SELECT");
}
}
}
this.FillVendorGrid();
}
Reply
Answers (
1
)
How to create Multi user chat application?
text file data uplaod in mysql database table