[英]how to search a control in an asp.net gridview and access it?
I have a gridview as:我有一个 gridview 为:
<asp:GridView ID="gvAppRejProfiles" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Resumes
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lbtnResumes" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
i have a list of resume names (string format) that i want to add as the text of the linkbutton "lbtnResumes" for all the resume names that i have in a string array.我有一个简历名称列表(字符串格式),我想将其添加为链接按钮“lbtnResumes”的文本,用于字符串数组中的所有简历名称。
make use of FindControl()
mehod....to search control利用
FindControl()
方法....搜索控件
void gvAppRejProfiles_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton bl =
(LinkButton)e.Row.FindControl("lbtnResumes");
}
}
for (int count = 0; count < gvAppRejProfiles.Rows.Count; count++)
{
LinkButton lbtnResumes = (LinkButton)gvAppRejProfiles.Rows[count].FindControl("lbtnResumes");
if (lbtnResumes.Text == "resume")
{
// Store and perform any operation
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.