从代码后面设置Css值 [英] Setting Css value from code behind

查看:99
本文介绍了从代码后面设置Css值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个页面,我在其中动态创建表格行和表格单元格并在其中添加控件.

如下所示

HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell();


tr.ID ="tr" + i.ToString();
tblPerSetngs.Controls.Add(tr );
CheckBox chk =新的CheckBox();
chk.ID ="chk" + i.ToString();
chk.Text = dtTechSkills.Rows [i] ["SkillName"].ToString ();


td.Controls.Add(chk);
tr.Controls.Add(td);
table.Controls.Add(tr);

>控件添加了wel和fine.但是现在我想将CSS样式设置为表格行.

在此先感谢
Naina

Hi

I have a page where i am creating table row and table cell dynamically and adding a control to in it.

It is as below

HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell();


tr.ID = "tr" + i.ToString();
tblPerSetngs.Controls.Add(tr);
CheckBox chk = new CheckBox();
chk.ID = "chk" + i.ToString();
chk.Text = dtTechSkills.Rows[i]["SkillName"].ToString();


td.Controls.Add(chk);
tr.Controls.Add(td);
table.Controls.Add(tr);

the control is adding wel and fine. but now i want to set the css style to the table row.

Thanks in advance
Naina

推荐答案

nainakarri写道:
nainakarri wrote:

该控件添加了很多内容.但现在我想将CSS样式设置为表格行.

the control is adding wel and fine. but now i want to set the css style to the table row.



tr.Attributes.Add("class","classname");



tr.Attributes.Add("class", "classname");


这篇关于从代码后面设置Css值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆