I need to iterate through a GridView and find the value of the Eval("name")
column of each selected row.
Code:
string title = "";
foreach (GridViewRow row in gdv.Rows)
{
if (row.BackColor.Equals(Color.LightGoldenrodYellow))
{
title += row.Cells[0].Text +开发者_如何学Go ", "; // doesn't work, even though the value i want is in the very first column
}
}
Try it this way (use your control and ID):
foreach (GridViewRow Row in GridView1.Rows)
{
Label MyLabel = Row.FindControl("Label1") as Label;
if (MyLabel != null)
{
Response.Write(MyLabel.Text);
}
}
精彩评论