i use a registration form in that based on one ddl1 it generate another ddl2
my problem is i using these in three tier architecture i dont know how to bind the ddl2 based on ddl1 .selectedvalue
here is my code 1.DAL.cs, 2.BAL.cs 3.registration form .cs
ddl ID="ddlstate"
1.DAL.cs
public DataTable Bind_ddlCity()
{
try
{
con = new SqlConnection(s);
con.Open();
string qry = "select state, from cntryandstate where cntry ='" + dd + "'";
cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
catch
{
throw;
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
}
2.BAL.Cs
public DataTable Bind_ddlCity()
{
try
{
return obj.Bind_ddlCity();
}
catch
{
throw;
}
finally
{
//obj = null;
}
}
3 .registration form .cs
private void Bind_ddlCity()
{
DataTable ret;
ret = obj.Bind_ddlCity();
if (ret.Rows.Count != 0)
{
ddlstate.DataSource = ret;
ddlstate.DataTextField = "state";
ddlstate.DataValueField = "cntry";
ddlstate.DataBind();
}
Dhirendra MisraPosted Jan 6, 2014, 5:28 AM
You can create new corresponding method for ddl2 in your DAL.cs, BLL.cs with parameter (selected value of ddl1) and in onSelectedIndexChange event of ddl1 you can bind ddl2. You can pass selected value as parameter to your new DAL and BLL method.
You can refer it:
http://www.codeproject.com/Questions/191898/DropDownList-and-capturing-values-after-SelectedIn