protected DataTable ckb_Select()
{
DataTable dt = new DataTable();
DataRow dr = null;
for (int i = 0; i < this.GVDansoumanger.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)this.GVDansoumanger.Rows[i].Cells[0].FindControl("ckSelect");
if (ckb.Checked)
{
dr = dt.NewRow();
dr["DangerousSourceCode"] dr[1]= GVDansoumanger.Rows[i].Cells[1].Text;
dr["Stairdepname"] = GVDansoumanger.Rows[i].Cells[2].Text;
dr["Twaindepname"] = GVDansoumanger.Rows[i].Cells[3].Text;
dr["threedepname"] = GVDansoumanger.Rows[i].Cells[4].Text;
dr["DangerousSourceName"] = GVDansoumanger.Rows[i].Cells[5].Text;
dr["DSLName"] = GVDansoumanger.Rows[i].Cells[6].Text;
dr["WorkingName"] = GVDansoumanger.Rows[i].Cells[7].Text; }
}
dt.Rows.Add(dr);
return dt;
}
这段代码我想实现,把一个GridView中的数据通过CheckBox的选择,从新导出一个DataTable中。
错误提示:DangerousSourceCode,Stairdepname没找到表的列。
如何写才正确!
解决方案 »
- 上传 大文件 有没有 好的解决方案 ?
- Repeater 使用
- 索引和长度必须引用该字符串内的位置。
- 使用oledb 连接绿色版sql server 2000(GSQL),执行update不报错,返回1,但是数据没有更新,谁知道什么原因?
- 上海ASP.NET全职合作
- Session_End 时 Session 还在吗? 怎么样获得正在 End 的这个会话的 SessionID?
- 有关控件和事件的问题,请各位大虾帮忙,急急急!
- 我在母版页的内容页中,加入的JS代码,在编译的时候他总是报JS运行时间错误,不知道是什么原因。。
- 使用SqlConnection和OleDbConnection操作数据库有什么区别?
- 从数据库中读图片问题?在线等!
- showModalDialog为什么不能打开一个相对路径的网页
- GridView 中HyperLink
这是什么。。
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
//你要替换的项
}
}
GridView中全选后要导出所有数据,不是当前页,但还要保证你选几个导出几个!
我弄了好几天,GridView不可能把所有页一下全选,
没办法,只好给客户弄个假象,让他点全选,然后我只不过从新去查询下数据库,然后在绑定别的控件输出Excel, 单选也是这样,所以就弄成现在这样!有什么好办法么?
你只声明了内存表,内存表里有那些列呢
你没有添加.就真接把选中的赋值给某例,所以会报Stairdepname没找到表的列。 先把在dgv里选中的行所有的例添加到内存表吧DataColumns dc=new DataColumns("列名称")
dt.Columns.add(dc);
依此类推,或写循环添加