If you have two combo boxes, and when one changes you want the other to
update its available items, is it possible to bind the second combo box
somehow using the getchildren method of the selected row from the first
combo box? how would you guys go about doing something like this with
ado.net? thanks

Re: tieing combo boxes to getchildren of a row by Greg

Greg
Wed Apr 28 15:07:30 CDT 2004

take a look at DataRelation. Bind one to the parent, bind the other to the
child.

"Brian Henry" <brianiupmsdn@newsgroups.nospam> wrote in message
news:%23OPoOTULEHA.1120@TK2MSFTNGP11.phx.gbl...
> If you have two combo boxes, and when one changes you want the other to
> update its available items, is it possible to bind the second combo box
> somehow using the getchildren method of the selected row from the first
> combo box? how would you guys go about doing something like this with
> ado.net? thanks
>
>



Re: tieing combo boxes to getchildren of a row by Brian

Brian
Wed Apr 28 16:28:36 CDT 2004

thanks

"Greg" <greg@cds-am.net> wrote in message
news:OkXpGxVLEHA.1272@tk2msftngp13.phx.gbl...
> take a look at DataRelation. Bind one to the parent, bind the other to
the
> child.
>
> "Brian Henry" <brianiupmsdn@newsgroups.nospam> wrote in message
> news:%23OPoOTULEHA.1120@TK2MSFTNGP11.phx.gbl...
> > If you have two combo boxes, and when one changes you want the other to
> > update its available items, is it possible to bind the second combo box
> > somehow using the getchildren method of the selected row from the first
> > combo box? how would you guys go about doing something like this with
> > ado.net? thanks
> >
> >
>
>



Re: tieing combo boxes to getchildren of a row by v-kevy

v-kevy
Wed Apr 28 21:06:53 CDT 2004

Thanks for Greg's quick response!

Hi Brian,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need the second combobox on the
form displays items according to child rows of the first combobox. If there
is any misunderstanding, please feel free to let me know.

I agree with Greg's suggestion to use GetChildRows on a DataRelation
object. It's better to use a typed DataSet for convenience. We can handle
the SelectedValueChanged event of the first combobox to change items in the
second one. Here I have written a code snippet for your reference. HTH.

private void Form1_Load(object sender, System.EventArgs e)
{
SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM Customers",
this.sqlConnection1);
SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM Orders",
this.sqlConnection1);
sda1.Fill(dataset11.Customers);
sda2.Fill(dataset11.Orders);

this.comboBox1.DisplayMember = "CompanyName";
this.comboBox1.ValueMember = "CustomerID";
this.comboBox1.DataSource = dataset11.Customers;

this.comboBox2.DisplayMember = "OrderDate";
this.comboBox2.ValueMember = "OrderID";
}

private void comboBox1_SelectedValueChanged(object sender,
System.EventArgs e)
{
if(this.comboBox1.SelectedValue != null)
{
this.comboBox2.DataSource =
dataset11.Customers.FindByCustomerID(this.comboBox1.SelectedValue.ToString()
).GetChildRows(dataset11.Relations["CustomersOrders"]);
}
}

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: tieing combo boxes to getchildren of a row by Brian

Brian
Wed Apr 28 21:16:22 CDT 2004

thanks both of you have helped a lot

"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:$Uq9j6YLEHA.3396@cpmsftngxa10.phx.gbl...
> Thanks for Greg's quick response!
>
> Hi Brian,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need the second combobox on the
> form displays items according to child rows of the first combobox. If
there
> is any misunderstanding, please feel free to let me know.
>
> I agree with Greg's suggestion to use GetChildRows on a DataRelation
> object. It's better to use a typed DataSet for convenience. We can handle
> the SelectedValueChanged event of the first combobox to change items in
the
> second one. Here I have written a code snippet for your reference. HTH.
>
> private void Form1_Load(object sender, System.EventArgs e)
> {
> SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM Customers",
> this.sqlConnection1);
> SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM Orders",
> this.sqlConnection1);
> sda1.Fill(dataset11.Customers);
> sda2.Fill(dataset11.Orders);
>
> this.comboBox1.DisplayMember = "CompanyName";
> this.comboBox1.ValueMember = "CustomerID";
> this.comboBox1.DataSource = dataset11.Customers;
>
> this.comboBox2.DisplayMember = "OrderDate";
> this.comboBox2.ValueMember = "OrderID";
> }
>
> private void comboBox1_SelectedValueChanged(object sender,
> System.EventArgs e)
> {
> if(this.comboBox1.SelectedValue != null)
> {
> this.comboBox2.DataSource =
>
dataset11.Customers.FindByCustomerID(this.comboBox1.SelectedValue.ToString()
> ).GetChildRows(dataset11.Relations["CustomersOrders"]);
> }
> }
>
> If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: tieing combo boxes to getchildren of a row by v-kevy

v-kevy
Thu Apr 29 02:05:27 CDT 2004

Hi Brian,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: tieing combo boxes to getchildren of a row by Mika

Mika
Thu Apr 29 07:30:58 CDT 2004

Hi!

I need this kind on thing also, but I don't understand what is
"FindByCustomerID" in the following C# sample below? I'm using VB.NET 2003,
maybe this same sample code as VB code would help me better to figure out
it.

--
Thanks in advance!

Mika

>
> private void Form1_Load(object sender, System.EventArgs e)
> {
> SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM Customers",
> this.sqlConnection1);
> SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM Orders",
> this.sqlConnection1);
> sda1.Fill(dataset11.Customers);
> sda2.Fill(dataset11.Orders);
>
> this.comboBox1.DisplayMember = "CompanyName";
> this.comboBox1.ValueMember = "CustomerID";
> this.comboBox1.DataSource = dataset11.Customers;
>
> this.comboBox2.DisplayMember = "OrderDate";
> this.comboBox2.ValueMember = "OrderID";
> }
>
> private void comboBox1_SelectedValueChanged(object sender,
> System.EventArgs e)
> {
> if(this.comboBox1.SelectedValue != null)
> {
> this.comboBox2.DataSource =
>
dataset11.Customers.FindByCustomerID(this.comboBox1.SelectedValue.ToString()
> ).GetChildRows(dataset11.Relations["CustomersOrders"]);
> }
> }