I had two dropdownlists. ddl1,ddl2
After selecting the value in the ddl1 data will be loaded in ddl2 data comes from sql database.
upto this all are working fine.
my requirement is...
while selecting the ddl1 page should not get loaded, but the values should be fetched in ddl2. "Should not use Update pannel."
can anyone help me with example coading...

Posted Oct 11, 2013, 6:26 AM
VenkiPosted Oct 11, 2013, 6:16 AM
VenkiPosted Oct 11, 2013, 6:06 AM
just like selecting states after selecting country.
Murali ReddyPosted Oct 11, 2013, 5:52 AM
suppose you have 2 classes one for each drop down list.
public class parent
{
public int Id {get;set;} //pk
public string name {get;set;}
}
public class child
{
public int Id {get;set;} //pk
public string childname {get;set;}
public virtual parent par {get;set;}
public int parId {get;set;} //fk
}
public class mainwindow
{
context db=new context();
var result=from name in db.parentlist
select name;
ddl1.selectedvaluepath="Id";
ddl1.displaymemberpath="Name";
ddl1.itemssource=result.tolist();
}
private void ddl1_selectedvaluechanged(object sender, SelectionChangedEventArgs e) //ddl1 item selected event
{
var val=ddl1.selectedvalue;
context db=new context();
var result=from n in db.childlist
where id=val
select n;
ddl2.itemssource=result.tolist();
}
Murali ReddyPosted Oct 11, 2013, 5:37 AM