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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. using binding context

using binding context

Scheduled Pinned Locked Moved C#
csswpfwcfsalesxml
1 Posts 1 Posters 1 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.
  • D Offline
    D Offline
    dhol
    wrote on last edited by
    #1

    Consider two tables as follows. 1) Parenttable--------------(tablename) code description-------------(column names) 1111 Red 1112 Blue 1113 Green 1114 Purple 1115 Yellow 2) childtable---------------------(tablename) code customer qty address -------------(column names) 1111 Kmart 3 fdsf 1112 Myer 4 ujjjjj 1111 Myer 5 gfjsfs 1111 BigW 2 hsvfs 1112 Kmart 12 sugs 1113 Coles 432 ssghs 1113 Myer 2 rfweq 1115 SafeWay 7 eepoo 1114 Biggg 788 uhff create these two tables in a xml file and read it to a dataset. create a relation ship for item code column. Now I have to add two datagrids in the program.Add data biniding for both the grids. Andshould bind one grid to parent table and bind one grid to child table. using dataviewmanager I have to do this. Now implement the binding context And add a button to your form in the click event of that button increase the binding context by 1. then u will see that according to parents table's code in the grid it will show only that items i n the child table grid.. This is my requirement. I have created 2 xml files with the data and added 2 datgrids. Private DataSet ds= new DataSet() Private void fngetconnected() { DataSet xml1 = new DataSet(); xml1.ReadXml("C:\\relation\\parentable.xml"); DataTable dt1 = xml1.Tables["parenttable"].Copy(); DataSet xml2 = new DataSet(); xml2.ReadXml("C:\\relation\\childtable.xml"); DataTable dt2 = xml2.Tables["childtable"].Copy(); ds.Tables.Add(dt1); ds.Tables.Add(dt2); DataColumn parentCol = ds.Tables["parenttable"].Columns["code"]; DataColumn childCol = ds.Tables["childtable"].Columns["code"]; DataRelation relTable1Table2; relTable1Table2 = new DataRelation("parentchild", parentCol, childCol); ds.Relations.Add(relTable1Table2); //Create Dataview setting for each table //using DataView Manager DataViewManager myDVM = new DataViewManager(ds); myDVM.DataViewSettings["parenttable"].Sort = "code DESC"; myDVM.DataViewSettings["childtable"].Sort = "code Desc"; dataGrid1.SetDataBinding(myDVM, "parenttable"); dataGrid2.SetDataBinding(myDVM, "childtable"); } I have added 2 datagrids and vreated a relation and set databinding to two grids such that one grid shows parenttable and another shows childtable. Now I have to add a button and when clicked, I have to see that accordi

    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