public void BindDataByCompanyID(string CompanyID, bool bAddSelectAll, string RoleCode, string AreaCode) { string strwhere = " 1=1 "; if (!String.IsNullOrWhiteSpace(CompanyID)) { strwhere += " and CompanyID=" + CompanyID; } if (!String.IsNullOrWhiteSpace(RoleCode) && !String.IsNullOrWhiteSpace(AreaCode)) { strwhere += " and RoleID in(SELECT a1.RoleID from T_Role a1 INNER JOIN T_Company b1 "; strwhere += " ON a1.CompanyID=b1.CompanyID AND b1.Area_Code='" + AreaCode + "' "; strwhere += " and LOWER(a1.RoleCode)='" + RoleCode.ToLower() + "')"; } List <T_UsersInfo_MDL> userlist = new List <T_UsersInfo_MDL>(); T_UsersInfo_BLL userBLL = new T_UsersInfo_BLL(); userlist = userBLL.DataTableToList(userBLL.GetList(0, strwhere, "userid").Tables[0]); if (bAddSelectAll == true) { T_UsersInfo_MDL mdl = new T_UsersInfo_MDL(); mdl.UserID = 0; mdl.UserName = "******"; userlist.Insert(0, mdl); } ddlUser.DataTextField = "username"; ddlUser.DataValueField = "userid"; ddlUser.DataSource = userlist; ddlUser.DataBind(); }