asp.net问题:错误提示:DataBinding: System.Data.DataRowView 不包含名为"xw_id"的属性
cs码是protectedvoidPage_Load(objectsender,EventArgse){stringsql="selecttop10xw_idxw_tit...
cs码是 protected void Page_Load(object sender, EventArgs e)
{
string sql = "select top 10 xw_id xw_title from xinwen order by xw_time desc";
SqlDataAdapter myAdap = new SqlDataAdapter(sql,DBHelper.connection);
DataSet myds = new DataSet();
myAdap.Fill(myds, "新闻中心表");
GridView1.DataSource = new DataView(myds.Tables[0]);
GridView1.DataBind();
}
aspx源码是<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="xw_id" ShowHeader="False">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="xw_id" DataNavigateUrlFormatString="xinwenzhongxin.aspx?id={0}"
DataTextField="xw_title" HeaderText="新闻标题" />
</Columns>
</asp:GridView>
怎么回事啊?明明查找了xw_id列的啊。。怎么说没有呢。。。
(xinwen表里面有xw_id这一列) 展开
{
string sql = "select top 10 xw_id xw_title from xinwen order by xw_time desc";
SqlDataAdapter myAdap = new SqlDataAdapter(sql,DBHelper.connection);
DataSet myds = new DataSet();
myAdap.Fill(myds, "新闻中心表");
GridView1.DataSource = new DataView(myds.Tables[0]);
GridView1.DataBind();
}
aspx源码是<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="xw_id" ShowHeader="False">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="xw_id" DataNavigateUrlFormatString="xinwenzhongxin.aspx?id={0}"
DataTextField="xw_title" HeaderText="新闻标题" />
</Columns>
</asp:GridView>
怎么回事啊?明明查找了xw_id列的啊。。怎么说没有呢。。。
(xinwen表里面有xw_id这一列) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询