首页 > 开发 > 综合 > 正文

任意在datagrid里面添加控件。

2024-07-21 02:16:45
字体:
来源:转载
供稿:网友
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,通吃  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表