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
Loading

Jitendra Patel138 reputationPosted Apr 6, 2010, 2:42 AM EDT
you can remove row or delete record....
please specify me because i will u.
Thanks,
Jitendra Patel
VasanthRank #1,487 · 1.1K reputationPosted Apr 6, 2010, 2:43 AM EDT
before delete the records , just show the confirmation message "Are you sure to delete ? " using javascript in onChange event.
[ Code Behind - C# ]
void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{
//bind the records
BindData();
}
}
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
{
CheckBox checkbox = (CheckBox)sender;
if (checkbox.Checked)
{
GridViewRow row = (GridViewRow)checkbox.NamingContainer;
string ID = row.Cells[1].Text;
//By using the ID , just delete the records in the database
//Call again and bind the records
BindData();
}
}
public void BindData()
{
//Bind the records from the database to the gridview.
}
If it helps out , please mark as answer.
charan sekhar92 reputationPosted Apr 6, 2010, 3:30 AM EDT
VasanthRank #1,487 · 1.1K reputationPosted Apr 6, 2010, 3:38 AM EDT
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
{
CheckBox checkbox = (CheckBox)sender;
if (checkbox.Checked)
{
GridViewRow row = (GridViewRow)checkbox.NamingContainer;
row.visible = false;
}
}
If it helps out , please mark as answer.
charan sekhar92 reputationPosted Apr 6, 2010, 8:51 PM EDT