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();
}

浙公网安备 33010602011771号