我需要遍历GridView并找到每个选定行的Eval("name")
列的值。
代码:
string title = "";
foreach (GridViewRow row in gdv.Rows)
{
if (row.BackColor.Equals(Color.LightGoldenrodYellow))
{
title += row.Cells[0].Text + ", "; // doesn't work, even though the value i want is in the very first column
}
}
答案 0 :(得分:0)
以这种方式尝试(使用您的控件和ID):
foreach (GridViewRow Row in GridView1.Rows)
{
Label MyLabel = Row.FindControl("Label1") as Label;
if (MyLabel != null)
{
Response.Write(MyLabel.Text);
}
}