我有这个问题绑定gridview,它是第一次工作,没有错误的分页或删除情况,它会显示错误,你帮我节省时间
DataBinding: '<>f__AnonymousType5`3[[System.Int32, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
[System.String, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a
这是我的数据绑定代码
var objBanner = from obj in dataContext.tbl_achevements
orderby obj.ID descending
select new
{
obj.ID,
obj.v_Year,
obj.Achivement
};
if (objBanner.Count() > 0)
{
lblMsg.Visible = false;
lblMsg.Text = "";
grdDetails.DataSource = objBanner;
grdDetails.DataBind();
}
这是Stack Trace:
[HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not
contain a property with the name 'System'.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName)
+12225118
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
+142
System.Web.UI.WebControls.BoundField.GetValue(Control controlContainer)
+164
System.Web.UI.WebControls.BoundField.OnDataBindField(Object sender,
EventArgs e) +71
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +304
System.Web.UI.Control.DataBindChildren() +12450431
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32
dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState,
Boolean dataBind, Object dataItem, DataControlField[] fields,
TableRowCollection rows, PagedDataSource pagedDataSource) +295
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding)