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
Savita Joshi
NA
129
133.1k
PLEASE PLEASE HELP ME ,ITS VERY URGENT...
May 1 2011 12:06 AM
Hi friends,
I am working on checkbox in GRIDVIEW. I want to delete all the selected records... I have this code below for your reference... Please help me to make it work ... Thanks....
protected void btnDelete_Click(object sender, EventArgs e)
{
string currentrow;
for (int index = 0; index <= GridView1.Rows.Count - 1; index++)
{
CheckBox cb = (CheckBox)GridView1.Rows[index].FindControl("chkDelete");
if (cb.Checked)
{
currentrow = GridView1.DataKeys[index].Value.ToString();
string constr = @"Data Source=OM;Initial Catalog=TestDB;Integrated Security=True";
string query = @"Delete FROM Categories where CategoryID='" + currentrow + "'";
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand(query);
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataSet ds = new DataSet();
da.Fill(ds, "Categories");
GridView1.DataSource = ds.Tables["Categories"];
GridView1.DataBind();
}
}
}
Reply
Answers (
22
)
I have this error String or binary data would be truncated
how to compare value from table with textbox value