【发布时间】:2018-01-10 23:16:29
【问题描述】:
我正在尝试在我的 C# 语法中使用以下代码将链接按钮添加到 asp:gridview。输出窗口显示添加的文本标签,因此代码似乎按照应有的方式进行了迭代。但是,当页面加载时,没有链接按钮。
我应该如何设置才能加载链接按钮?
protected void gvRR_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
string[] rrar= new string[] { "Value Basis For Customer Support:" };
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell row in e.Row.Cells)
{
if (rrar.Any(x => x == e.Row.Cells[1].Text))
{
LinkButton lb = new LinkButton();
lb.ID = "lbcoded";
lb.Text = e.Row.Cells[1].Text;
e.Row.Cells[1].Controls.Add(lb);
System.Diagnostics.Debug.Print("Label Added");
}
}
}
}
【问题讨论】:
标签: c# asp.net gridview webforms