我在后台生成表格:
newCells.Text = @"<td>"+ aabbccee("3") +"</td>";
protected System.Web.UI.WebControls.LinkButton aabbccee(string inta)
{
LinkButton a = new LinkButton();
a.ID = "LinkButton" + inta;
a.CommandArgument=inta;
a.Command += LinkButton1_Click;
a.Text = "移除产品";
return a;
}
可调用时却显示成了:System.Web.UI.WebControls.LinkButton,而没有显示“移除产品”,怎么解决这个问题啊?
newCells.Text = @"<td>"+ aabbccee("3") +"</td>";
protected System.Web.UI.WebControls.LinkButton aabbccee(string inta)
{
LinkButton a = new LinkButton();
a.ID = "LinkButton" + inta;
a.CommandArgument=inta;
a.Command += LinkButton1_Click;
a.Text = "移除产品";
return a;
}
可调用时却显示成了:System.Web.UI.WebControls.LinkButton,而没有显示“移除产品”,怎么解决这个问题啊?
你的newCells是个什么控件???
GridViewRow rowSeparator = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
//行的背景颜色
rowSeparator.BackColor = System.Drawing.ColorTranslator.FromHtml("#f9fbfc");
//设置单元格,根据实际情况增加,我这儿是增加一个跨所有列的行
TableCell separatorCell = new TableCell(); Literal newCells = new Literal(); //是这个。。
separatorCell.Controls.Add(aabbccee("3"))
这样子没有问题。但我要增加的行是类似这样子的:
字符 字符 控件 字符 控件 //几列不固定,输出是控件还是字符得视aabbccee("3")而定。如果调用的是aabbccee("3")就是要显示控件
我这样写:Literal newCells = new Literal();
newCells.Text = "<td>字符</td><td>" + aabbccee("3")+"</td>";
separatorCell.Controls.Add(newCells);那输出时就成为了:字符 System.Web.UI.WebControls.LinkButton 问题还是没有解决,哭。。