开发者

How To Put Data At Run Time In a Table i.e Table Also Create At The Run Time?

i am trying to put data as a summery 开发者_运维技巧in my application from data table in a label but i want to put data in a table inspite of label such that table also create a t run time wile my code is putting data ina label at run time .. .

 for (int m = 0; m < dtGroupedByDate.Rows.Count; m++)
 {
      Label Date = new Label();
      Date.Text = dtGroupedByDate.Rows[m][0].ToString();
      Date.Style["margin-left"] = (m > 0) ? "20px" : "0px";
      this.Controls.Add(Date);
      Label PowerSum = new Label();
      PowerSum.Text = dtGroupedByDate.Rows[m][1].ToString();
      PowerSum.Style["margin-left"] = "20px";
      this.Controls.Add(PowerSum);
 }

Hopes for your suggestions... Regards,


suppose your data is in a datatable dt

then

 DataTable dt = new DataTable();
        Table mytable = new Table();
        this.Controls.Add(mytable);
        mytable.DataBind(dt);


You can use HtmlTable control

Here you can find an example of looping through a list and adding rows dynamically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜