c# – 在创建动态表时应用Css样式

c# – 在创建动态表时应用Css样式,第1张

概述这是我的问题: >当我在C#中创建表时,我想为每个单元格添加不同的CSS样式. 而(DR.Read())         { TableRow linha1 = new TableRow(); cel1 = new TableCell(); cel2 = new TableCell(); cel3 = new TableCell(); cel4 = new Tabl 这是我的问题:

>当我在C#中创建表时,我想为每个单元格添加不同的CSS样式.

而(DR.Read())
        {

tableRow linha1 = new tableRow();    cel1 = new tableCell();    cel2 = new tableCell();    cel3 = new tableCell();    cel4 = new tableCell();    cel1.Controls.Add(new literalControl(DR.GetValue(0).ToString()));    cel2.Controls.Add(new literalControl(DR.GetValue(1).ToString()));    cel3.Controls.Add(new literalControl(DR.GetValue(2).ToString()));    cel4.Controls.Add(new literalControl(DR.GetValue(3).ToString()));    linha1.Controls.Add(cel1);    linha1.Controls.Add(cel2);    linha1.Controls.Add(cel3);    linha1.Controls.Add(cel4);    Tab_artigos_all.Controls.Add(linha1);}
解决方法 它实际上很容易.

cel1.Style["CsspROPERTY"] = "SomeValue"

要么

cel1.Attributes.Add("class","CSSCLASSname");

那应该这样做

总结

以上是内存溢出为你收集整理的c# – 在创建动态表时应用Css样式全部内容,希望文章能够帮你解决c# – 在创建动态表时应用Css样式所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1222211.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存