.NET关于Repeater如何遍历里面的CheckBox,并且怎么获取每一列的值!(三张表的)

时间:2021-08-27 10:50:42

SuperRoles.Model.SuperRoles_UesrRoles user = new SuperRoles.Model.SuperRoles_UesrRoles();           

  string companyid = Request.QueryString["companyid"];           

  string name = Request.QueryString["UserName"];          

   foreach (Control item in this.rep_user.Controls)           

  {

                CheckBox ck = (CheckBox)item.FindControl("isckture");                

      TextBox tbx = (TextBox)item.FindControl("tbxTableName");                

       TextBox tbid = (TextBox)item.FindControl("guid");               

        string role = tbx.Text;                

      Guid id = Guid.Parse(tbid.Text);                

       if (ck != null)             

          {                   

          if (ck.Checked)       

                  {

                          if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().SelectByUserNameAndId(name, id, role))                 

                  {                      

              MessageBox.ShowAndRedirect("修改权限成功", "CompanyMember_List.aspx");                       

                    }                       

                    else  {                       

                            if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().Insert(companyid, id, name, role))  

 

                            {  MessageBox.ShowAndRedirect("添加用户角色成功", "CompanyMember_List.aspx");       

                                          }

                       

}                

  }                       else    {    

                      if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().Delete(id, name))                 

                {  MessageBox.ShowSlideSuccess("修改权限成功");

                        }                     }                 }                 else               

  {                     MessageBox.ShowSlideError("删除用户全部角色");                 }

                }             }          

public void SelectByName()       

  {            

string name = Request.QueryString["UserName"];

            foreach (Control item in this.rep_user.Controls)            

        {                

TextBox tbx = (TextBox)item.FindControl("tbxTableName");                

TextBox tbid = (TextBox)item.FindControl("guid");                

string role = tbx.Text;                

Guid id = Guid.Parse(tbid.Text);                

CheckBox ck = (CheckBox)item.FindControl("isckture");                

if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().SelectByUserNameAndId(name, id, role))               

  {                     ck.Checked = true;                 }             }

        }     } }