AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
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 asp.net 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
Hi,

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
The Beginner's Guide to Joomla
FierceDeveloper
When Good HTML Goes Bad: How You Can Protect Your Web Applications