FindControl in GridView Footer

  • Thread starter Thread starter Andrew Robinson
  • Start date Start date
A

Andrew Robinson

I am using the following code to preload a few controls in the FooterRow
within a GridView control:

protected void Page_Load(object sender, EventArgs e) {
((TextBox)GriwViewRates.FooterRow.FindControl("TextBoxRateInsert")).Text
= "60";
}

The successfully loads the Footer / TextBox on page load but fails to load
the Footer / TextBox when the GridView is Paged. The line still executes
without exception (so it is finding the control) but the value seems to be
lost. Is there something going on with paging that I am missing here? My
TextBox is being over written by something?


Thanks,


Andy
 
Found the answer to this shortly after posting. The following fixes the
missing data on paging.

Never mind.

protected void GridViewRates_RowDataBound(object sender,
GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.Footer) {
((TextBox)e.Row.FindControl("TextBoxRateInsert")).Text = "60";
}
}
 
Back
Top