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
charan sekharPosted Apr 7, 2010, 12:51 AM
VasanthPosted Apr 6, 2010, 7:38 AM
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 sekharPosted Apr 6, 2010, 7:30 AM
VasanthPosted Apr 6, 2010, 6:43 AM
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.
Jitendra PatelPosted Apr 6, 2010, 6:42 AM
you can remove row or delete record....
please specify me because i will u.
Thanks,
Jitendra Patel