SqlDataSource实现动态Sql语句

 protected void datasourceAuthority_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        if (int.Parse(this.ddlFunction.SelectedValue) == 0)
            e.Command.CommandText = "select auty.AuthoritySN,auty.emp_no,emp.emp_name,auty.AuthorityItemSN,auty.AuthorityItemName,auty.active from GMMailAuthority auty join  emp_data_all emp  on auty.emp_no=emp.emp_no where auty.emp_no like '" + this.txtEmpNo.Text.Trim() + "' + '%'";
        else
            e.Command.CommandText = "select auty.AuthoritySN,auty.emp_no,emp.emp_name,auty.AuthorityItemSN,auty.AuthorityItemName,auty.active from GMMailAuthority auty join  emp_data_all emp  on auty.emp_no=emp.emp_no where auty.emp_no like '" + this.txtEmpNo.Text.Trim() + "' + '%' and  auty.AuthorityItemSN=" + this.ddlFunction.SelectedValue.ToString();

    }

posted @ 2008-11-13 08:26  只想做好  阅读(1053)  评论(0)    收藏  举报