good evening to all..............
I have one dropdownlist with 5 or 6 item and one checkboxlist populate on dropdownlist value.
my .aspx page code is given below..
<asp:DropDownList ID="ddlstDesignation" AutoPostBack="true" runat="server" Width="193px" onselectedindexchanged="ddlstDesignation_SelectedIndexChanged" Height="25px"> <asp:ListItem Value="--Select--">--Select--</asp:ListItem> <asp:ListItem Value="1">National Sales Manager</asp:ListItem> <asp:ListItem Value="2">Region Manager</asp:ListItem> <asp:ListItem Value="3">Branch Manager</asp:ListItem> <asp:ListItem Value="4">Area Manager</asp:ListItem> <asp:ListItem Value="5">Supervisor</asp:ListItem>
<asp:ListItem Value="6">Salesman</asp:ListItem> </asp:DropDownList>
<cc1:CheckBoxListExCtrl ID="CheckBoxListExCtrl1" RepeatDirection="Horizontal" RepeatColumns="2" runat="server"> </cc1:CheckBoxListExCtrl>
on selecting of dropdownlist value the checkboxlist is populate its work good....but when i select the dropdownlist value every time its submitt the page ...
i need javascript for this selectedindexchange....
my code behind .aspx.cs file are given below
private void BindCheckboxList(string designation)
{
if (designation == "1")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = "SELECT Convert(varchar, NSM.NationalSalesManagerCode)+ ' - ' + NSM.NationalSalesManagerName + ' / ' + C.CountryName As NationalSalesManagerName, NSM.NationalSalesManagerCode FROM NationalSalesManager NSM INNER JOIN Country C ON NSM.NationalSalesManagerCode = C.NationalSalesManagerCode ORDER BY NationalSalesManagerName";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "NationalSalesManagerName";
CheckBoxListExCtrl1.DataValueField = "NationalSalesManagerCode";
CheckBoxListExCtrl1.DataBind();
}
else if (designation == "2")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = "SELECT Convert(varchar, RMgr.RegionManagerCode)+ ' - ' + RMgr.RegionManagerName + ' / ' + RMst.RegionMstName As RegionManagerName, RMgr.RegionManagerCode FROM RegionManager RMgr INNER JOIN RegionMaster RMst ON RMgr.RegionManagerCode = RMst.RegionManagerCode ORDER BY RMgr.RegionManagerCode";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "RegionManagerName";
CheckBoxListExCtrl1.DataValueField = "RegionManagerCode";
CheckBoxListExCtrl1.DataBind();
}
else if (designation == "3")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = Cmd = "SELECT Convert(varchar, BMgr.BranchManagerCode)+ ' - ' + BMgr.BranchManagerName + ' / ' + DMst.DepotName As BranchManagerName, BMgr.BranchManagerCode FROM BranchManager BMgr INNER JOIN DepotMaster DMst ON BMgr.BranchManagerCode = DMst.BranchManagerCode ORDER BY BMgr.BranchManagerCode";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "BranchManagerName";
CheckBoxListExCtrl1.DataValueField = "BranchManagerCode";
CheckBoxListExCtrl1.DataBind();
}
else if (designation == "4")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = Cmd = Cmd = "SELECT Convert(varchar, AreaManagerCode)+ ' - ' + AreaManagerName As AreaManagerName, AreaManagerCode FROM AreaManager ORDER BY AreaManagerCode";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "AreaManagerName";
CheckBoxListExCtrl1.DataValueField = "AreaManagerCode";
CheckBoxListExCtrl1.DataBind();
}
else if (designation == "5")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = Cmd = Cmd = Cmd = "SELECT Convert(varchar, SupervisorCode)+ ' - ' + SupervisorName As SupervisorName, SupervisorCode FROM Supervisor ORDER BY SupervisorCode";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "SupervisorName";
CheckBoxListExCtrl1.DataValueField = "SupervisorCode";
CheckBoxListExCtrl1.DataBind();
}
else if (designation == "6")
{
ConnDeemah.Open();
SqlDataReader nsmDr;
Cmd = Cmd = Cmd = Cmd = Cmd = "SELECT Convert(varchar, SalesmanCode)+ ' - ' + SalesmanName1 As SalesmanName, SalesmanCode FROM Salesman ORDER BY SalesmanCode";
SqlCommand RCMD = new SqlCommand(Cmd, ConnDeemah);
nsmDr = RCMD.ExecuteReader(CommandBehavior.CloseConnection);
CheckBoxListExCtrl1.DataSource = nsmDr;
CheckBoxListExCtrl1.DataTextField = "SalesmanName";
CheckBoxListExCtrl1.DataValueField = "SalesmanCode";
CheckBoxListExCtrl1.DataBind();
}
}
protected void ddlstDesignation_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlstDesignation.SelectedValue == "1")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
else if (ddlstDesignation.SelectedValue == "2")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
else if (ddlstDesignation.SelectedValue == "3")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
else if (ddlstDesignation.SelectedValue == "4")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
else if (ddlstDesignation.SelectedValue == "5")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
else if (ddlstDesignation.SelectedValue == "6")
{
CheckBoxListExCtrl1.Visible = true;
BindCheckboxList(ddlstDesignation.SelectedValue);
}
}
i need javascript slectedindex change means when i select a dropdownlist value then populate the checkboxlist using javascript
please help me...thanks