从代码后面设置Css值 [英] Setting Css value from code behind
问题描述
您好,我有一个页面,我在其中动态创建表格行和表格单元格并在其中添加控件.
如下所示
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
推荐答案
该控件添加了很多内容.但现在我想将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屋!