protected void DDLstate_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("select City from Mst_City where State='"+DDLstate.SelectedValue+"'",con);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Mst_City");
DDLcity.DataSource = ds;
DDLcity.DataBind();
}
here in above code data retrived when am debugging but it will show system.data.datarowview in dropdownlist when am change in state from state dropdownlist
Loading

Satyapriya NayakPosted May 22, 2013, 2:22 AM
Pankaj PandeyPosted May 22, 2013, 12:55 AM
try this...
protected void DDLstate_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("select City from Mst_City where State='"+DDLstate.SelectedValue+"'",con);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Mst_City");
DDLcity.DataSource = ds;
DDLcity.DataTextField="Mst_City";
DDLcity.DataValueField ="Mst_City";
DDLcity.DataBind();
}
or
protected void DDLstate_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("select City from Mst_City where State='"+DDLstate.SelectedValue+"'",con);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Mst_City");
DDLcity.DataTextField="Mst_City";
DDLcity.DataValueField ="Mst_City";
DDLcity.DataSource = ds;
DDLcity.DataBind();
}
I hope it will help you.
Mark as answered if helpfull
Bhabani prasad DashPosted May 22, 2013, 12:51 AM
protected void DDLstate_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("select City from Mst_City where State='"+DDLstate.SelectedValue+"'",con);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Mst_City");
DDLcity.DataSource = ds.Tables["Mst_City"];
// DDLcity.DataTextField = "City"; // This is text displayed
DDLcity.DataValueField = "City"; // This is the value returned
DDLcity.DataBind();
}