我正在尝试从 GridView 中生成的行中获取数据。这是我的桌子:
protected void viewStoryTime_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Row.Cells[0].Text);
}
输出是:
小时 6.25 3 5 4
但是,我需要日期列中的数据。但是当我这样做时:
protected void viewStoryTime_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Row.Cells[2].Text);
}
我收到以下错误:
System.ArgumentOutOfRangeException was unhandled by user code
Specified argument was out of the range of valid values.
Parameter name: index
我不明白我做错了什么。