首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么在gridview中插入数据绑定

2013-07-08 
如何在gridview中插入数据绑定请高手帮忙,谢啦~[解决办法]SqlConnection con new SqlConnection(global:

如何在gridview中插入数据绑定
请高手帮忙,谢啦~怎么在gridview中插入数据绑定
[解决办法]


SqlConnection con = new SqlConnection(global::System.Configuration.ConfigurationManager.ConnectionStrings["ZX_WYZJConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            con.Open();
            String sql = "select a.CatalogCode,a.UserCode,a.Code,a.Title,a.Text,a.PostDatetime,b.UserName,c.Name from tb_Question a left join tb_UserInfo b on b.Code=a.UserCode left join tb_Catalog c on c.Code=a.CatalogCode order by a.PostDatetime";
            SqlDataAdapter sda = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            sda.Fill(ds, "tb_Question");
            GridView1.DataSource = ds;
            GridView1.DataKeyNames = new string[] { "Code" };
            GridView1.DataBind();
            con.Close();

[解决办法]
引用:
Quote: 引用:

要将数据持久化到数据库是吗?
恩,就是想在gridview中插入数据绑定,如图所示那样,实现访问数据库和存储数据到数据库的目的?


gridview使用示例不懂再问
[解决办法]
截图右上角点那个按钮“>”,点击编辑列,然后就可以添加绑定列了

热点排行