Databinding with intermediary table

Discussion in 'ASP .Net Web Controls' started by Zebrahead, Mar 28, 2007.

  1. Zebrahead

    Zebrahead Guest

    Hi all,

    I have a dataset with 3 tables:
    1. Items with columns: ItemId, Name
    2. Categories with columns: CategoryId, name
    3. ItemsCategory with columns: ItemId, CategoryId (serves to identify which
    items belong to which categories.)

    When the user selects a category from a dropdown list I need to display the
    Items for that category in another dropdown list. Before I used to go to the
    database every time and get the data with a query like:

    SELECT Items.ItemId, Items.Name FROM Items, ItemsCategory WHERE
    ItemsCategory.CategoryId = list.SelectedIndex and Items.ItemId =
    ItemsCategory.ItemId.

    How do I perform a similar query with a dataset?

    So far I have been able to get the Items for the selected Category by using:

    DataView cView = new DataView(ItemsSet.Tables["ItemsCategory"],
    "","CategoryId", DataViewRowState.CurrentRows);
    DataRowView[] foundRows = cView .FindRows(new object[]
    {list.SelectedIndex.ToString()});

    But I am unable to make my Items dropdown list display only those Items.
    (The Items.ItemId column is the Items' dropdown list's datavaluefield)
    Creating a datarelation between the Items and ItemsCategory table has no
    effect and creating a datarelation berween Items and DataRowView generates an
    error.

    Any suggestions and/or links to tutorials greatly appreciated!

    Thanks in advance!

    Zebrahead.
    Zebrahead, Mar 28, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pos
    Replies:
    0
    Views:
    369
  2. pos
    Replies:
    1
    Views:
    566
    Hugo Pragt
    Feb 27, 2004
  3. pos
    Replies:
    0
    Views:
    468
  4. jobs
    Replies:
    0
    Views:
    1,595
  5. Earl Teigrob
    Replies:
    1
    Views:
    386
    Shravan
    Mar 1, 2004
Loading...

Share This Page