Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem figuring out DataGridView

Problem figuring out DataGridView

Scheduled Pinned Locked Moved C#
helpdatabasetutorialannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PyroManiak
    wrote on last edited by
    #1

    I've got 2 columns, Column Catagory, and Column Item. I've got them displaying from drop down boxes, but when I pick a catagory, I dont know how to force the Item Column to update for the items from the selected Catagory. I hope that made sense... (no, I'm not doing this for homework, and my database doesn't actually involve cars) [Catagory] [Item] |Car| |Acura| |Truck| |Accord| |Tacoma| Hopefully the above is a reasonable "view" of what I've got. There is a catagory table, and an item table. The item table has the catagory number from catagory table with each item. Thanks for the help.

    K 2 Replies Last reply
    0
    • P PyroManiak

      I've got 2 columns, Column Catagory, and Column Item. I've got them displaying from drop down boxes, but when I pick a catagory, I dont know how to force the Item Column to update for the items from the selected Catagory. I hope that made sense... (no, I'm not doing this for homework, and my database doesn't actually involve cars) [Catagory] [Item] |Car| |Acura| |Truck| |Accord| |Tacoma| Hopefully the above is a reasonable "view" of what I've got. There is a catagory table, and an item table. The item table has the catagory number from catagory table with each item. Thanks for the help.

      K Offline
      K Offline
      kjosh
      wrote on last edited by
      #2

      Hi, DataSet ds; DataViewManager dsview; In the form_load write this: string constr = "Data Source=KALPANA\\KAL; Trusted_Connection = yes;Database=Northwind"; SqlConnection con = new SqlConnection(constr); SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM category", con); ds = new DataSet("category"); da1.TableMappings.Add("Table", "category"); da1.Fill(ds); SqlDataAdapter da2 = new SqlDataAdapter("SELECT * FROM item", con); da2.TableMappings.Add("Table", "item"); da2.Fill(ds); string dt = ""; for (int i = 0; i < ds.Tables.Count; i++) { dt += "Table Mappings" + i.ToString() + " " + ds.Tables[i].ToString() + " "; } //MessageBox.Show(dt); DataRelation relcatitem; DataColumn colmast; DataColumn coldet; colmast= ds.Tables["category"].Columns["catid"]; coldet = ds.Tables["item"].Columns["catid"]; relcatitem = new DataRelation("relcatitem", colmast, coldet); ds.Relations.Add(relcatitem); for(int j=0;j

      1 Reply Last reply
      0
      • P PyroManiak

        I've got 2 columns, Column Catagory, and Column Item. I've got them displaying from drop down boxes, but when I pick a catagory, I dont know how to force the Item Column to update for the items from the selected Catagory. I hope that made sense... (no, I'm not doing this for homework, and my database doesn't actually involve cars) [Catagory] [Item] |Car| |Acura| |Truck| |Accord| |Tacoma| Hopefully the above is a reasonable "view" of what I've got. There is a catagory table, and an item table. The item table has the catagory number from catagory table with each item. Thanks for the help.

        K Offline
        K Offline
        kjosh
        wrote on last edited by
        #3

        Hi, Reply me whether my code is works for u or not.By seeing ur question i tried that program.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups