日期:2014-05-17  浏览次数:20518 次

动态生成table加CSS+js


            string connStr = ConfigurationManager.ConnectionStrings["sqlservercon"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                   
                        cmd.CommandText = "select * from T_BoWen";
                    SqlDataReader reader = cmd.ExecuteReader();


                    TableRow Row1 = new TableRow();
                 
                    TableCell cell1 = new TableCell();
                    cell1.Attributes.Add("style", "width:20px;font-weight:bolder;");
                    cell1.Text ="标题";
                    //此位置用来写博客名的超链接
                    TableCell cell2 = new TableCell();
                    cell2.Attributes.Add("style", "width:655px;font-weight:bolder;");
                    cell2.Text ="" ;


                    TableCell cell3 = new TableCell();
                    cell3.Attributes.Add("style", "width:50px;font-weight:bolder;");
                    cell3.Text ="阅读";
                    


                    TableCell cell4 = new TableCell();
                    cell4.Attributes.Add("style", "width:80px;font-weight:bolder;");
                    cell4.Text = "评论";
                   


                    TableCell cell5 = new TableCell();
                    cell5.Attributes.Add("style", "width:130px;font-weight:bolder;");
                    cell5.Text = "评论权限";
                    


                    TableCell cell6 = new TableCell();
                    cell6.Attributes.Add("style", "width:120px;font-weight:bolder;");
                    cell6.Text = "操作";


                    Row1.Cells.Add(cell1);
                    Row1.Cells.Add(cell2);
                    Row1.Cells.Add(cell3);
      &nb