如何在gridview中找到在锚标签下传递的图像。 [英] how to find image which is passed under anchor tag in gridview.
本文介绍了如何在gridview中找到在锚标签下传递的图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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>
这是用aspx页面编写的代码。
i希望在gridview中找到图像,并根据角色使其禁用或不可见。
this is the code written in aspx page.
i want to find image in gridview and make it disable or invisible based on role.
推荐答案
使用RowDataBound
事件GridView
。
添加runat =server
到img
标签,否则将其更改为asp:Image
。
执行以下操作。
UseRowDataBound
Event ofGridView
.
Addrunat="server"
to theimg
Tag, else change it toasp:Image
.
Do something like below.
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;
}
}
}
这篇关于如何在gridview中找到在锚标签下传递的图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文