【发布时间】:2014-04-10 11:30:53
【问题描述】:
我正在使用实体框架并希望在网格视图上绑定数据但面临问题我有我正在粘贴的代码以及附加屏幕截图我也看到了关于这个问题的答案但对我没有好处所以任何人都有经验必须感谢这个错误。
aspx.cs 代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
lblMessage.Text = "";
}
void BindGrid()
{
using (GapEntities1 context = new GapEntities1())
{
if (context.Organizations.Count() > 0)
{
// GdvOrganization is a gridview ID name
GdvOrganization.DataSource = context.Organizations;
GdvOrganization.DataBind();
}
}
}
【问题讨论】:
标签: asp.net entity-framework gridview datasource