如何将gridview数据存储到datatable中 [英] how to store the gridview data into datatable

查看:315
本文介绍了如何将gridview数据存储到datatable中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将网格视图数据存储到数据表中。我的代码如下:

  if (rbw.Checked ==  true 
{
Sql = 从Tb_Staff_Doubt_Register中选择类别,问题,答案,其中%等问题 + Txtsearch.Text + %'或答案如% + Txtsearch.Text + %';
Dr = SCon.ReadSql(Sql);
GridView1.DataSource = Dr;
GridView1.DataBind();
GridView1.Visible = true ;
}



如何将上面的网格视图数据存储到数据表中?请帮助我。



问候,

Narasiman P.

解决方案

只需复制并粘贴以下代码,您的所有网格数据都将在datatable dt中。







< pre lang =cs> if (rbw.Checked == true
{
Sql = 选择类别,问题,答案来自Tb_Staff_Doubt_Register问题如'%' + Txtsearch .Text + %'或类似'%'的答案 + Txtsearch.Text + %';
Dr = SCon.ReadSql(Sql);
GridView1.DataSource = Dr;
GridView1.DataBind();
GridView1.Visible = true ;
DataTable dt = GridVeiw1.DataSource as DataTable;
}


how to store the grid view data into data table.My code as follows:

if (rbw.Checked == true)
{
  Sql = "select Category,Questions,Answers from Tb_Staff_Doubt_Register Where Questions like '%" + Txtsearch.Text + "%' or Answers like '%" + Txtsearch.Text + "%' ";
  Dr = SCon.ReadSql(Sql);
  GridView1.DataSource = Dr;
  GridView1.DataBind();
  GridView1.Visible = true;
}


How to store the above grid view data into data table? Please help me.

Regards,
Narasiman P.

解决方案

just copy and paste the below code all your grid data will be in datatable dt.



if (rbw.Checked == true)
{
Sql = "select Category,Questions,Answers from Tb_Staff_Doubt_Register Where Questions like '%" + Txtsearch.Text + "%' or Answers like '%" + Txtsearch.Text + "%' ";
Dr = SCon.ReadSql(Sql);
GridView1.DataSource = Dr;
GridView1.DataBind();
GridView1.Visible = true;
DataTable dt=GridVeiw1.DataSource as DataTable;
}


这篇关于如何将gridview数据存储到datatable中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆