Chào các bạn,
Tình hình là mình bị lỗi
A field or property with the name '' was not found on the selected data source
Đây Giao diện gridview của mình
Code:
<asp:GridView ID="grvNews" runat="server" AutoGenerateColumns="False" Width="360px">
<Columns>
<asp:BoundField HeaderText="ID" DataField="id" />
<asp:BoundField HeaderText="Title" DataField="title" SortExpression="title" />
<asp:BoundField HeaderText="Content VN" DataField="contentVN" SortExpression="contentVN" />
<asp:BoundField HeaderText="Content Eng" DataField="contentENG" SortExpression="contentENG" />
<asp:BoundField HeaderText="Date" DataField="newsDate" SortExpression="newsDate"/>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />
</Columns>
<EditRowStyle BackColor="#F0FFF0" />
<FooterStyle BackColor="#F0FFF0" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#FF0000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F0FFF0" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F0FFF0" />
</asp:GridView>
Code:
public string id
{
get { return _id; }
set {_id=value ;}
}
public string title
{
get { return _title; }
set { _title = value; }
}
public string content_vn
{
get { return _content_vn; }
set { _content_vn = value; }
}
public string content_en
{
get { return _content_en; }
set { _content_en = value; }
}
public string news_date
{
get { return _news_date; }
set { _news_date = value; }
}
Code:
public List<news_admin> News_GetByAll()
{
List<news_admin> list = new List<news_admin>();
using (SqlCommand cmd = new SqlCommand("sp_news_GetByAll", openConnect()))
{
news_admin obj = new news_admin();
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
list.Add(NewsIDataReader(dr));
}
}
dr.Close();
obj = null;
}
return list;
}
Mình code theo mô hình 3 tier
Nó báo lỗi ở gridview không nhận được cột contentVN, khi mình xóa 3 cột cuối đi thì nó nhận 2 cột ID và Title nhưng lại hiển thị Title vào cột ID @@