使用Gridview的数据绑定 [英] Databind with Gridview

查看:74
本文介绍了使用Gridview的数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用gridview将表中的数据绑定。

how bind data from table with gridview.

推荐答案



如果您使用数据集,请使用这样的代码




if you use Dataset, please use code like this

DataSet ds=new DataSet();
SqlDataAdapter dataadpt=new SqlDataAdapter(cmd);
dataadpt.Fill(ds);
//now we bind data to grid view
Gridview1.DataSource=ds;
Gridview1.Databind();





如果你使用DataTable,

与数据集相同。但差别很小



if you use DataTable,
same as dataset.but small difference is

Gridview1.DataSource=ds.Tables[0];
Gridview1.Databind();





因为Datatable的集合被称为DataSet。



希望这对你有用,



谢谢和问候

Angappan.S



because Collection of Datatable is called as DataSet.

Hope this is useful to you,

Thanks and regards
Angappan.S


谷歌是你的朋友:好好经常拜访他。他可以比在这里发布问题更快地回答问题...



一次非常快速的搜索得到超过50万次点击:使用gridview 绑定表中的数据[ ^ ]

顶部链接看起来很有趣!



将来请尝试自己做至少基础研究,而不是浪费你的时间或我们的时间。
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search gave over half a million hits: bind data from table with gridview[^]
The top link looks interesting!

In future, please try to do at least basic research yourself, and not waste your time or ours.


这篇关于使用Gridview的数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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