Binding dropdown list in a gridview edit item template

Posted by Renju on Stack Overflow See other posts from Stack Overflow or by Renju
Published on 2009-03-07T08:29:32Z Indexed on 2010/04/04 3:03 UTC
Read the original article Hit count: 342

Filed under:
|
|
|

i can bind the dropdownlist in the edit item template. The drop down list is having null values.

protected void grdDevelopment_RowDataBound(object sender, GridViewRowEventArgs e) 
{   
  DropDownList drpBuildServers = new DropDownList();

  if (grdDevelopment.EditIndex == e.Row.RowIndex)    
  {        
      drpBuildServers = (DropDownList)e.Row.Cells[0].FindControl("ddlBuildServers");    
  }
}

also getting an error

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

© Stack Overflow or respective owner

Related posts about gridview

Related posts about ASP.NET