B
Ben
In C#, I have a GridView that bounds to a DataView.
When the user click a certain button, I want it to go through the
gridview rows and update some object based on an ID.
The ID should be invisible... so I put a <LABEL> in one of the cells
and trying to access it via FindControl... but it's always returning
null.
I even made each LABEL have it's own ID (being equal to MonitorID1, 2,
3... etc), it's still not getting it.. here's a snippet, maybe someone
has ideas on what's wrong?
protected void btnSetMaintenance_Click(object sender, EventArgs e)
{
int iCount = 0;
foreach (GridViewRow gvr in gridIssues.Rows)
{
Label lbl =
(Label)gvr.Cells[1].FindControl("MonitorID" + iCount.ToString());
if(lbl != null)
Response.Write(lbl.Text + "<BR>");
else
Response.Write("not found (" + gvr.Cells[1].Text +
iCount.ToString() + "<BR>");
iCount++;
}
}
Thank you!
When the user click a certain button, I want it to go through the
gridview rows and update some object based on an ID.
The ID should be invisible... so I put a <LABEL> in one of the cells
and trying to access it via FindControl... but it's always returning
null.
I even made each LABEL have it's own ID (being equal to MonitorID1, 2,
3... etc), it's still not getting it.. here's a snippet, maybe someone
has ideas on what's wrong?
protected void btnSetMaintenance_Click(object sender, EventArgs e)
{
int iCount = 0;
foreach (GridViewRow gvr in gridIssues.Rows)
{
Label lbl =
(Label)gvr.Cells[1].FindControl("MonitorID" + iCount.ToString());
if(lbl != null)
Response.Write(lbl.Text + "<BR>");
else
Response.Write("not found (" + gvr.Cells[1].Text +
iCount.ToString() + "<BR>");
iCount++;
}
}
Thank you!