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
Dipa Ahuja
NA
3.1k
713.7k
how to delete multiple records from gridview based on checkbox
Mar 11 2010 10:58 AM
i used this way.. bt its not working.. whats wrong in this ?
protected void btnDltMul_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("cbRows");
// System.Windows.Forms.MessageBox.Show(chk.ToString());
if (chk.Checked == true)
{
string sid = ((Label)GridView1.Rows[i].FindControl("lblsid")).Text;
objcon.Open();
// System.Windows.Forms.MessageBox.Show(sid.ToString());
SqlCommand comm = new SqlCommand("DELETE from scraps where toId=@toId AND sid=@sid", objcon);
comm.Parameters.AddWithValue("@toId", p.profile_Id);
comm.Parameters.AddWithValue("@sid", Convert.ToInt32(sid.ToString()));
comm.ExecuteNonQuery();
objcon.Close();
GridView1.DataBind();
}
}
GridView1.DataBind();
//upscrap.Update();
}
Reply
Answers (
2
)
Programmatically adding javascipt code in c#
sessions in asp.net