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