DataTable里Rows[i][1]提取到值是数据库中控件的名称,想实现最终效果类似这样:btnXTJS.Enabled = false;
......

解决方案 »

  1.   

    http://dev.csdn.net/article/57/57990.shtm
    http://www.cnblogs.com/cairabbit/archive/2004/10/18/53693.aspx
      

  2.   

    如有好办法解决请到这里来领100分。http://community.csdn.net/Expert/topic/3737/3737781.xml?temp=.5430719
      

  3.   

    DataTable dtPer = GetUserPermission(frmLogin.userName);
    bool flag = false;
    for(int i = 0; i < dtPer.Rows.Count; i++)
    {
        string permission = dtPer.Rows[i][1].ToString();
        object obj=this.GetType().GetField(permission ).GetValue(this);
        if (obj !=null)
        {
    Button bt=obj as Button;
    bt.Enabled = flag ;
        }
    }
      

  4.   

    你所有的操作都是在组织一个字符串当然不行了.
    试试下面的代码
    DataTable dtPer = GetUserPermission(frmLogin.userName);

    foreach(Control ctl in this.Controls)
    {
    for(int i = 0; i < dtPer.Rows.Count; i++)
    {
    if(ctl.Name == dtPer.Rows[i][1].ToString())
    {
    ctl.Enabled = false;
    }
    }
    }