示例#1
0
 private void createData()
 {
     zs.BLL.Sys_Role       bllr  = new zs.BLL.Sys_Role();
     zs.BLL.Sys_UserRole   bllur = new zs.BLL.Sys_UserRole();
     zs.Model.Sys_UserRole model = new zs.Model.Sys_UserRole();
     foreach (RepeaterItem ri in Repeater1.Items)
     {
         (ri.FindControl("ddl_role") as DropDownList).DataSource     = bllr.GetModelList("");
         (ri.FindControl("ddl_role") as DropDownList).DataTextField  = "RoleName";
         (ri.FindControl("ddl_role") as DropDownList).DataValueField = "ID";
         (ri.FindControl("ddl_role") as DropDownList).DataBind();
         //(ri.FindControl("ddl_role") as DropDownList).SelectedValue =
         string userId = (ri.FindControl("HiddenField1") as HiddenField).Value;
         if (bllur.GetModelList("UserID=" + userId).Count > 0)
         {
             model = bllur.GetModelList("UserID=" + userId)[0];
             (ri.FindControl("ddl_role") as DropDownList).SelectedValue = model.RoleID.Value.ToString();
         }
     }
 }
示例#2
0
 private void BindData()
 {
     this.ddl_role.DataSource     = bllr.GetModelList("");
     this.ddl_role.DataTextField  = "RoleName";
     this.ddl_role.DataValueField = "ID";
     this.ddl_role.DataBind();
     if (Request.QueryString["id"] != null)
     {
         string ids = Request.QueryString["id"].ToString();
         if (ids != "0")
         {
             zs.Model.Tbl_User model = bll.GetModel(int.Parse(ids));
             this.tb_name.Text           = model.userName;
             this.tb_Psw.Text            = model.userPsw;
             this.ddl_role.SelectedValue = bllur.GetModelList("UserID=" + ids)[0].RoleID.ToString();
             this.Button1.Text           = "修改";
             ViewState["userid"]         = ids;
         }
     }
 }