CSDN博客

img rickjelly2004

任意在datagrid里面添加控件。

发表于2004/7/1 10:06:00  1297人阅读

分类: ASP。NET的经典收藏

任意在datagrid里面添加控件。

转贴:Andy.m   日期:2003-07-12   人气:55
ICollection CreateDataSource()
        {
            DataTable dt = new DataTable();
            DataRow dr;

            dt.Columns.Add(new DataColumn("主题", typeof(string)));
            dt.Columns.Add(new DataColumn("发布单位", typeof(string)));
            dt.Columns.Add(new DataColumn("发布时间", typeof(string)));
            dt.Columns.Add(new DataColumn("删除",typeof(string)));

                
            SqlDataReader myreader1=new dbconn().getreader("select * from bbs");
            while (myreader1.Read())
            {
                dr = dt.NewRow();
   
                dr[0] = "<a href='showbbs.aspx?id=" + Convert.ToString(myreader1.GetValue(0)) + "'>" + myreader1.GetString(1) + "</a>" ;
                dr[1] = myreader1.GetString(3);
                dr[2] = Convert.ToString(myreader1.GetValue(4));
                //HtmlInputCheckBox checkbox=new HtmlInputCheckBox();
                //checkbox.ID="hello";
                //checkbox.Visible=true;
                dr[3]="<input type=checkbox id='todel' name='todel' value='" + Convert.ToString(myreader1.GetValue(0)) + "'>";


                dt.Rows.Add(dr);
            }

有了这个,随便你是datagrid还是datalist,通吃  
0 0

相关博文

我的热门文章

img
取 消
img