加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 00:04:00 所属栏目:百科 来源:网络整理
导读:这是我的问题: 当我在C#中创建表时,我想为每个单元格添加不同的CSS样式. 而(DR.Read()) ????????{ TableRow linha1 = new TableRow(); cel1 = new TableCell(); cel2 = new TableCell(); cel3 = new TableCell(); cel4 = new TableCell(); cel1.Controls.Ad
这是我的问题:

>当我在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");

那应该这样做

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读