使用以下代码行,我可以打印行的主键:
protected void storyGridView_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
System.Diagnostics.Debug.WriteLine(DataBinder.Eval(e.Row.DataItem, "PK_NonScrumStory"));
}
但是我不能将值分配给字符串变量:
和
如何获取分配给变量的值?
编辑:
堆栈跟踪:
[NullReferenceException: Object reference not set to an instance of an object.]
user_nonscrumstories2.storyGridView_OnRowDataBound(Object sender, GridViewRowEventArgs e) in c:\Users\tunnelld2\Documents\Visual Studio 2012\Websites\ZSA_New 21\user\nonscrumstories2.aspx.cs:424
System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +111
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +181
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2188
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +123
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974