问题描述
它显然不似乎是一个不可能完成的问题,但我不能找到一种方法来填充HtmlTable控件(这是从codebehind访问)与已装满数据的HTMLTABLE对象。
任何人可以帮助我在这?
问候,
修改
在ASP页,我有ID的HTML表=表1
在codebehind,我首先从列表填充的HTMLTABLE对象做这样的:
HTMLTABLE localTable1 =新HTMLTABLE();
HtmlTableCell CELL1 =新HtmlTableCell();
HtmlTableCell CELL 2 =新HtmlTableCell();的foreach(在theEvaluations评价EVAL)
{
HtmlTableRow anEvaluation =新HtmlTableRow(); cell1.InnerText = eval.attr1;
anEvaluation.Cells.Add(CELL1); cell2.InnerText = eval.attr2;
anEvaluation.Cells.Add(CELL 2); localTable1.Rows.Add(anEvaluation);
}//而最终在这里,我应该通过localTable1表1的
好吧,我终于拥有了一切工作,乐剩下的问题只是由于对HtmlTableCell对象错误的申报地点。
下面是一个工作片段:
的foreach(在theEvaluations评价EVAL)
{
HtmlTableRow anEvaluation =新HtmlTableRow();
HtmlTableCell CELL1 =新HtmlTableCell();
HtmlTableCell CELL 2 =新HtmlTableCell();
cell1.InnerText = eval.attr1;
anEvaluation.Cells.Add(CELL1); cell2.InnerText = eval.attr2;
anEvaluation.Cells.Add(CELL 2); table1.Rows.Add(anEvaluation); //表1:在ASP页面的真正HTML表
}
It apparently doesn't seem to be an impossible question, but I can't find a way to populate an HtmlTable control (which is accessible from codebehind) with an HtmlTable object already filled with data.
Can anybody help me on this ??
Regards,
EDIT
In the ASP page, I have an HTML table with ID="table1"
In codebehind, I first populate an HtmlTable Object from a List doing like this :
HtmlTable localTable1 = new HtmlTable();
HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
foreach (Evaluation eval in theEvaluations)
{
HtmlTableRow anEvaluation = new HtmlTableRow();
cell1.InnerText = eval.attr1;
anEvaluation.Cells.Add(cell1);
cell2.InnerText = eval.attr2;
anEvaluation.Cells.Add(cell2);
localTable1.Rows.Add(anEvaluation);
}
// And eventually here I should pass the localTable1 to table1
Ok, I eventually have everything working, le remaining problem was just due to a wrong declaration place for the HtmlTableCell objects.
Here is a working snippet :
foreach (Evaluation eval in theEvaluations)
{
HtmlTableRow anEvaluation = new HtmlTableRow();
HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
cell1.InnerText = eval.attr1;
anEvaluation.Cells.Add(cell1);
cell2.InnerText = eval.attr2;
anEvaluation.Cells.Add(cell2);
table1.Rows.Add(anEvaluation); // table1 : the real HTML table in ASP page
}
这篇关于填充HTMLTABLE控制在ASP / C#HTMLTABLE对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!