C# 如何使用C在GridView中获取值#

C# 如何使用C在GridView中获取值#,c#,asp.net,C#,Asp.net,如何访问GridView中的值,在这种情况下,我在其中有一个target\u date,希望获取该值并将其转换为字符串。以下是我所拥有的: foreach (GridViewRow gr in GridView1.Rows) { CheckBox cb = (CheckBox)gr.FindControl("chkItem"); if (cb.Checked) { string strTargetDate = "???"; // TODO } } 使用此代码

如何访问GridView中的值,在这种情况下,我在其中有一个
target\u date
,希望获取该值并将其转换为字符串。以下是我所拥有的:

foreach (GridViewRow gr in GridView1.Rows)
{
   CheckBox cb = (CheckBox)gr.FindControl("chkItem");
   if (cb.Checked)
   {
      string strTargetDate = "???"; // TODO
   }
}
使用此代码:

foreach (GridViewRow gr in GridView1.Rows)
{
   var cells = gr.Cells;
   CheckBox cb = (CheckBox)gr.FindControl("chkItem");
   if (cb.Checked)
   {
      string strTargetDate = cells[0].Text;
   }
}
那一定是什么样子的 GridView1.Rows[(int)rowIndex].Cells[(int)ColIndex].Value; 或
GridView1.Rows[(int)rowIndex].Cells[(string)ColName].Value

它说,细胞的名称不存在exist@moe使用
gr.Cells[0]。文本