
GridView与下拉菜单DropDownList的组合。
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
namespace Exercise1.DepMng{ public partial class UserM2 : System.Web.UI.Page { Helper he = new Helper(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Bind(); } } public void Bind() { string user_sql = select * from User; DataSet ds = he.GetDataSet(user_sql, User); GridView1.DataSource = ds; GridView1.DataKeyNames = new string[] { UserID }; GridView1.DataBind(); //设置DropDownList默认值μ DropDownList ddl; for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { DataRowView mydrv = ds.Tables[0].DefaultView[i]; ddl = (DropDownList)GridView1.Rows[i].FindControl(depList); ddl.SelectedValue = ds.Tables[0].Rows[i][DepId].ToString(); ddl = (DropDownList)GridView1.Rows[i].FindControl(roleList); ddl.SelectedValue = ds.Tables[0].Rows[i][RId].ToString(); } } public DataSet ddlbind() { string sql = select * from Department; DataSet ds = he.GetDataSet(sql, Department); return ds; }
全部评论 (0)


