在所选数据源上找不到名称为"RequestID"的字段或属性. [英] A field or property with the name 'RequestID' was not found on the selected data source.
本文介绍了在所选数据源上找不到名称为"RequestID"的字段或属性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
请帮助
我有此代码用于gridview数据绑定.
我的桌子上有一行
Hello
Plz help
I have this code for gridview data bind.
I have one row in table
protected void Page_Load(object sender, EventArgs e)
{
string connection = "Data Source=ip;Initial Catalog=commonlogin;User ID=sa;Password=; ";
SqlConnection conn = new SqlConnection(connection);
conn.Open();
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM tbl_SqlImage", conn);
//SqlCommand cmd = new SqlCommand("SELECT * FROM tbl_SqlImage", conn);
//SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ad.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
我收到以下错误:
在所选数据源上找不到名称为"RequestID"的字段或属性.
请帮助
I get following error:
A field or property with the name ''RequestID'' was not found on the selected data source.
Plz help
推荐答案
更改
GridView1.DataSource = ds;
到
to
GridView1.DataSource = ds.Tables[0];
确保所使用的数据集的此表中存在映射到网格中的所有列.
Make sure all the columns mapped in your grid is present in this table of your dataset used.
您可能有一个绑定列,该绑定列绑定到"RequestID"列,但不在其中您的tbl_SqlImage表
You might have a bound column which is bound to column "RequestID", but that is not in your tbl_SqlImage table
这篇关于在所选数据源上找不到名称为"RequestID"的字段或属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文