Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<a href="ManageUserRoledeatilsPopup.aspx?userId=<%# Eval("userId")%>" rel="gb_page_center[980, 150]" title="Edit Manage User Role">
<img src="../images/edit-icon.png" width="21" height="24" alt="Edit User" title="Edit User" id = "imgedit" /></a>

this is the code written in aspx page.
i want to find image in gridview and make it disable or invisible based on role.
Posted
Updated 23-Feb-14 23:01pm
v2
Comments
Kornfeld Eliyahu Peter 24-Feb-14 5:04am    
You may consider jQuery, however for detailed answer you have to add more details of your scenario...

1 solution

Use RowDataBound Event of GridView.
Add runat="server" to the img Tag, else change it to asp:Image.

Do something like below.
C#
protected void YourGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{   
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // Find Image control.
        Image imgEdit = (Image)e.Row.FindControl("imgedit");
        
        if (someLogic)
        { 
            imgEdit.Visible = true; 
        }
        else 
        { 
            imgEdit.Visible = false; 
        }
    }
}
 
Share this answer
 

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