首页 新闻 搜索 专区 学院

如何动态绑定Table,从后台往前台绑定

0
[待解决问题]

如何动态绑定Table,从后台往前台绑定。

Angel90的主页 Angel90 | 初学一级 | 园豆:200
提问于:2011-04-14 10:02
< >
分享
所有回答(1)
0

for (int i = 1; i < dt.Rows.Count-1; i++)
        {
            System.Web.UI.HtmlControls.HtmlTableRow tr1 = new System.Web.UI.HtmlControls.HtmlTableRow();
            tr1.Height = "25"; tr1.Align = "left"; tr1.VAlign = "middle"; tr1.BgColor = "#ffffff";
            foreach (DataColumn dc_detail in dt.Columns)
            {
                System.Web.UI.HtmlControls.HtmlTableCell td1 = new System.Web.UI.HtmlControls.HtmlTableCell();
                td1.Align = "center"; td1.Align = "center";
                if (dt.Columns[dc_detail.Caption].ToString() == "Month_Rating")
                {
                    td1.InnerHtml = dt.Rows[i][dc_detail].ToString() == "" ? "" : Convert.ToDouble(dt.Rows[i][dc_detail].ToString()) > 60 ? dt.Rows[i][dc_detail].ToString() : string.Format("<font color=\"red\">{0}</font>", dt.Rows[i][dc_detail].ToString());
                }
                else
                {
                    td1.InnerHtml = dt.Rows[i][dc_detail].ToString();
                }
                tr1.Cells.Add(td1);
                tb1.Rows.Add(tr1);
            }
        }

like%'远远'% | 园豆:635 (小虾三级) | 2011-04-14 13:02
其实我知道了,在后台是用List集合绑定到数据源控件上,前台只需要直接绑定字段就好了,谢谢了!
支持(0) 反对(0) Angel90 | 园豆:200 (初学一级) | 2011-04-14 15:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册