绑定在GridView的编辑项模板下拉列表 [英] Binding dropdown list in a gridview edit item template

查看:250
本文介绍了绑定在GridView的编辑项模板下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以绑定在编辑项模板DropDownList中。下拉列表null值。

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");    
  }
}

也得到一个错误

无法加载视图状态。到被加载视图状态的控件树必须在使用了previous请求期间保存视图状态控件树相匹配。例如,动态添加控制时,一个后回过程中添加的控制必须初始请求过程中添加的控制的类型和位置相匹配。

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.

推荐答案

HTTP://www.$c$cproject.com/KB/webforms/editable_gridview_control.aspx ,它可能会有所帮助。

try http://www.codeproject.com/KB/webforms/editable_gridview_control.aspx , it could be helpful

这篇关于绑定在GridView的编辑项模板下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆