0
when I am trying to bind data to GridView in asp.net it shows the error "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'o_id'..". can anyone one please help me.
this is my database table fields:
o_id int primary key identity(1,1),
o_date nvarchar(20) ,
o_time nvarchar(20),
name_project nvarchar(60),
.aspx页面中数据绑定: 'System.Data.DataRowView' 不包含与名称的属性 'o_id'
<asp:GridView ID="GvProj" runat="server" AllowPaging="True" CssClass="AllGrid"
PagerStyle-CssClass="pgrAll" DataKeyNames="o_id">
<PagerStyle CssClass="pgrAll"></PagerStyle>
<RowStyle BackColor="#ffffff" ForeColor="#000000" />
<HeaderStyle BackColor="#4a70d0" ForeColor="#ffffff" />
<AlternatingRowStyle BackColor="#c0c0c0" ForeColor="#000000"FontSize="14px" />
</asp:GridView>
.cs文件
cmd.CommandText =“选择o_id作为ID,o_date作为DATE,name_project作为来自OrderManagement的NAME“;
int count = cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
GvProj.DataSource = dt;
GvProj.DataBind();
GvProj.Visible = true;
GvInvidual.Visible = false;
你在哪里绑定你的db列到gridview? – Webruster
我只想从名为“OrderManagement”的表中选择数据库数据,并希望在名为“GvProj”的gridview中显示。 – Abdu
但是,当我给DataViewName在GridView属性中不起作用。否则它的工作 – Abdu