Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one dropdown list it's binding from database using sqldatasource,i need pass
parameter and without parameter that dropdown.

i have two roles. both roles i was passing parameters.

1.admin
2.user

if i have both roles i need both roles data also.

Thanks for advance.

What I have tried:

in .aspx page
-------------
Business Unit


<asp:dropdownlist width="150" cssclass="form-control input-sm" id="ddlBusiness" runat="server" datatextfield="BusinessUnit" datavaluefield="ID" ondatabound="ddlBusiness_DataBound">

<asp:sqldatasource id="SqlDataSource5" runat="server" connectionstring="<%$ ConnectionStrings:DBSPTConnectionString %>" selectcommand="select [id],[businessunit] from [VBusinessMaster]">


<asp:sqldatasource id="SqlDataAdmin" runat="server" connectionstring="<%$ ConnectionStrings:DBSPTConnectionString %>">
<selectparameters>
<asp:parameter name="roleid" dbtype="Int32">



<asp:sqldatasource id="SqlDatauser" runat="server" connectionstring="<%$ ConnectionStrings:DBSPTConnectionString %>">
<selectparameters>
<asp:parameter name="roleid" dbtype="Int32">




in aspx.cs
----------------
var user = ubll.getUserbyGID(Session["userid"].ToString()).ToList();
if (user != null && user.Count > 0)
{

if (user.Where(d => d.RoleID == 1).Count() > 0)
{
divAdminMenu.Visible = true;
divBusiness.Visible = true;

SqlDataAdmin.SelectCommand = "select [id],[businessunit] from [VBusinessMaster] where roleid=@roleid";
SqlDataAdmin.SelectParameters["roleid"].DefaultValue = "1";
ddlBusiness.DataSourceID = "SqlDataAdmin";
ddlBusiness.DataBind();


}
if (user.Where(d => d.RoleID == 2).Count() > 0)
{
divUserMenu.Visible = true;
divBusiness.Visible = true;
SqlDatauser.SelectCommand = "select [id],[businessunit] from [VBusinessMaster] where roleid=@roleid";
SqlDatauser.SelectParameters["roleid"].DefaultValue = "2";
ddlBusiness.DataSourceID = "SqlDatauser";
ddlBusiness.DataBind();
//ddlBusiness.DataSourceID = "SqlDataSource5";
//ddlBusiness.DataBind();

}
Posted
Comments
DerekT-P 24-May-20 7:14am    
What question do you have for us?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900