asp.net 异常:"DataBinding: 'System.Data.DataRowView'

gridview帮定数据之后,出现

System.Web.HttpException was unhandled by user code
  Message="DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Topic'."
  Source="System.Web"
  ErrorCode=-2147467259
  StackTrace:
       at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName)
       at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
       at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
       at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data)
       at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at System.Web.UI.WebControls.GridView.DataBind()
       at TopicList.SetBind() in e:\SOLUTION\Forum\TopicList.aspx.cs:line 34
       at TopicList.Page_Load(Object sender, EventArgs e) in e:\SOLUTION\Forum\TopicList.aspx.cs:line 20
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

上面就是trace内容,我就不知道那个Topic是哪里的,最后在属性窗口的DataKeyNames就是Gridview的主键里发现了Topic,可能当时忘记了,改掉,重试,通过。

你可能感兴趣的:(asp.net)