Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,
My problem is that I have a grid view which is binded to a Table.When I check a particular row with the help of check box ,that row should removed from grid view but not from the database.How to remove the particular row from grid view.
Thanks with Regards,
Amit
Posted
Updated 3-Aug-10 23:50pm
v2

C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {
       GridView1.SelectedRow.Visible = false;
   }
 
Share this answer
 
Comments
koool.kabeer 4-Aug-10 16:44pm    
good and quick
Or you can hide the row using JavaScript -
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        LinkButton lnk = e.Row.Cells[0].Controls[0] as LinkButton;
        if (lnk != null)
        {
            lnk.OnClientClick = string.Format("document.getElementById('{0}').style.display = 'none'; return false;", e.Row.ClientID);
        }
    }
}


This code assumes that the "Select" link is in the first column.
 
Share this answer
 
Comments
koool.kabeer 4-Aug-10 16:44pm    
exactly needed answer...if no postback needed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900