Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 how to remove the row from the gridview control when check box is unchecked
Posted by charan on  4/6/2010 4:54:17 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
hi iam using with c#

in my gridview 1st column is templatefield which contains check box control,

default i set to check, iam displaying data at page load event

but when i unchecked the checkbox then that row should be remove from gridview .

can you give me example which helps me

Post Your Reply Post New Question

 Viewer's Reply
Remove GridView Row in CheckBox Uncheck
Answered By Moderator1 on 4/6/2010 8:59:43 AM

Make the CheckBox AutoPostBack property as true and write the code at its CheckBox1_CheckedChanged event as below,

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
foreach (GridViewRow gvr in GridView1.Rows)
CheckBox gvrChk = (CheckBox)gvr.FindControl("CheckBox1");
if (!gvrChk.Checked)
//Write code to remove the row and bind the GridView again.
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
Programmers Heaven C# School Book - Free 338 Page eBook
Integrating Silverlight 4 with SharePoint 2010 - Free 42 Page Sample Chapter
Simply SQL - Free 111 Page Preview!