gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 13:27:30 24 4
gpt4 key购买 nike

这是我的问题:

  • 当我用 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 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10977834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com