I have the following code for populating a dropdownlist in my gridviews footer.
if (!IsPostBack)
{
GridViewRow FooterRow = (GridViewRow)grdTime.FooterRow;
if (FooterRow != null)
{
QuartersTableAdapter Quarters = new QuartersTableAdapter();
DropDownList ddMonStart = (DropDownList)FooterRow.FindControl("ddMonStart");
ddMonStart.DataSource = Quarters.GetQuarters();
ddMonStart.DataTextField = "QuarterHour";
ddMonStart.DataValueField = "QuarterHour";
ddMonStart.DataBind();
}
}
Now I have done this in another application, and it works fine, but in this instance, nothing it being bound to the dropdown list, because FooterRow is never not Null.
Anyone know why footerRow may not be available?
Thanks
Do you bind the grid before or after this code?
The footer row will not exist before gridview.databind() is called.
Perhaps the better solution for you is to place this code in gridview.RowCreated method
with this check