B
barney
Hi,
I'm trying to get a kind of dependency to 2 dropdownlists in asp.net:
|Dropdown Vendor| -> 1:n -> |Dropdown Order|
After selecting a Vendor the 2nd Dropdownbox should only show Orders
linked to the selected Vendor. ( Both Dropdowns do autopostback )
But it always shows all values ...
Maybee someone has a tip for me ...
I trY:
if ( ! Page.IsPostBack ) {
string dsn = "...";
SqlConnection sql = new SqlConnection( dsn );
SqlCommand cmd1 = new SqlCommand("select id_vendor, name from
def_vendor", sqlC);
SqlCommand cmd2 = new SqlCommand("select id_vendor, id_po, quantity
from wrk_order", sqlC);
sqlC.Open();
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
ds = new DataSet("myds");
da1.Fill( ds, "vendor" );
da2.Fill (ds, "po" );
ds.Relations.Add("map_vendor_po",
ds.Tables["vendor"].Columns["id_vendor"],
ds.Tables["po"].Columns["id_vendor"]);
DropDownList1.DataSource = ds.Tables["vendor"];
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "id_vendor";
DropDownList1.DataBind();
DropDownList2.DataSource = ds.Relations["map_vendor_po"].ChildTable;
DropDownList2.DataTextField = "id_po";
DropDownList2.DataValueField = "id_po";
DropDownList2.DataBind();
}
Many thanks in advance
Tobias
(e-mail address removed)
I'm trying to get a kind of dependency to 2 dropdownlists in asp.net:
|Dropdown Vendor| -> 1:n -> |Dropdown Order|
After selecting a Vendor the 2nd Dropdownbox should only show Orders
linked to the selected Vendor. ( Both Dropdowns do autopostback )
But it always shows all values ...
Maybee someone has a tip for me ...
I trY:
if ( ! Page.IsPostBack ) {
string dsn = "...";
SqlConnection sql = new SqlConnection( dsn );
SqlCommand cmd1 = new SqlCommand("select id_vendor, name from
def_vendor", sqlC);
SqlCommand cmd2 = new SqlCommand("select id_vendor, id_po, quantity
from wrk_order", sqlC);
sqlC.Open();
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
ds = new DataSet("myds");
da1.Fill( ds, "vendor" );
da2.Fill (ds, "po" );
ds.Relations.Add("map_vendor_po",
ds.Tables["vendor"].Columns["id_vendor"],
ds.Tables["po"].Columns["id_vendor"]);
DropDownList1.DataSource = ds.Tables["vendor"];
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "id_vendor";
DropDownList1.DataBind();
DropDownList2.DataSource = ds.Relations["map_vendor_po"].ChildTable;
DropDownList2.DataTextField = "id_po";
DropDownList2.DataValueField = "id_po";
DropDownList2.DataBind();
}
Many thanks in advance
Tobias
(e-mail address removed)