如何在C#中动态地改变一列跨度的TD? [英] How to change colspan of a td dynamically in c#?
本文介绍了如何在C#中动态地改变一列跨度的TD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< FooterTemplate>
< TR风格=背景色:橙色;>
< TD WIDTH =6%ALIGN =中心ID =tdFooter=服务器合并单元格=3>
< / TD>
< / TR>
< / FooterTemplate>
我在,我有这个页脚模板的Repeater控件。我想要的是某些人的基础上,改变tdFooter的合并单元格在ItemDataBound事件(C#),如果clauses.How我可以做同样的?
如果(e.Item.ItemType == ListItemType.Footer)
{
如果(角色= 0)
{
// tdfooter列跨度应该是3
}
其他
{
// tdfoote合并单元格应为2
}
}
解决方案
我要中用runat添加到TD标记
< TD =服务器ID =tdControl>
在的ItemDataBound:
VAR TD =(HtmlTableCell)e.Item.FindControl(tdControl);
td.Attributes.Add(合并单元格,mynumber的);
<FooterTemplate>
<tr style="background-color:Orange;">
< td width="6%" align="center" id = "tdFooter" runat = "server" colspan = "3">
</td>
</tr>
</FooterTemplate>
I have a repeater control in which i have this footer template. All i want is to change the colspan of tdFooter at itemdatabound event(c#) on the basis of some if clauses.How can i do the same?
if (e.Item.ItemType == ListItemType.Footer)
{
if(role = 0)
{
//tdfooter colspan should be 3
}
else
{
//tdfoote colspan should be 2
}
}
解决方案
I would add a runat to the td tag
<td runat="server" id="tdControl">
in the itemdatabound:
var td = (HtmlTableCell)e.Item.FindControl("tdControl");
td.Attributes.Add("colspan", myNumber);
这篇关于如何在C#中动态地改变一列跨度的TD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文