Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How to disable AutoGenerateEditButtonfor single row in gridview?
Posted
Comments
sanjaysgh 26-Oct-13 6:06am    
you have to disable coloum of gridview
sanjaysgh 26-Oct-13 6:06am    
according to condition

NOTE: not familiar with VB.. but you can use any of the online converter's to convert the example code in VB. or at least this will give you some idea.

You can use Gridview's onRowDataBound event for this purpose.

Get the Editbutton from specific row in this method as each row is bounded after traversing this event. and just disable this.

I hope this will give you some idea.

C#
protected void YourGridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
    LinkButton lb = (LinkButton)(e.Row.Cells[0].Controls[0]); // if edit button is at index 0 i.e cell zero. or change it as per your req.

     string value = e.Row.Cells[2].Text; // if U wana disable it on some cell's specific value.
    if(value == "What you want")
        {
            lb.Visible = false;
        }

    }

}



Hope this will help. :)
 
Share this answer
 
v2
Comments
[no name] 28-Oct-13 2:48am    
Thanks it works. My 5
VICK 28-Oct-13 7:53am    
Glad to see you helped. :)
You can do this on row databound of gridview
 
Share this answer
 
Comments
[no name] 28-Oct-13 2:47am    
The question was Home and not Where!!!

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