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. databinding on a datagrid

databinding on a datagrid

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

    Hi I was about to design a form witha datgrid and some buttons with certain operations namely first, previous ,next and last and some text boxes I have to read two xml file( each xml file has one table)with data in it. Now I have to create a relation between the two tables and display it in the datagrid. Now using databinding I have to show the data from the datagrid columns to each text box when teh next, previous ...etc buttons r clicked. that is values from one column for ex: column name :DESC values :MR BROS, VT BROS, CT BROS when next is clicked, the values should be shown from the desc in to the textbox one by one. This i have did it this is the folowing code private DataSet ds = new DataSeyt(); retrieve button click private void RetrieveButton_Click_1(object sender, System.EventArgs e) { DataSet xml1 = new DataSet(); xml1.ReadXml("C:\\CDEV\\Relation\\cost_code.xml"); DataTable dt1 = xml1.Tables["cost_code"].Copy(); DataSet xml2 = new DataSet(); xml2.ReadXml("C:\\CDEV\\Relation\\cost_type.xml"); DataTable dt2 = xml2.Tables["cost_type1"].Copy(); ds.Tables.Add(dt1); ds.Tables.Add(dt2); DataColumn parentCol = ds.Tables["cost_type1"].Columns["cost_type"]; DataColumn childCol = ds.Tables["cost_code"].Columns["cost_type"]; DataRelation relTable1Table2; relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol); ds.Relations.Add(relTable1Table2); this.dataGrid1.DataSource = ds.Tables["cost_type1"]; fnDataBindingforTextBoxes(); fnSetCurrencyManager(); } private void fnDataBindingforTextBoxes() { this.ultraCostPaid.DataBindings.Add("Text", ds.Tables["cost_code"],"desscost_paid_by_us"); this.ultraCostType.DataBindings.Add("Text", ds.Tables["cost_code"],"cost_type"); } private void fnSetCurrencyManager() { currManager=(CurrencyManager)this.BindingContext[ds.Tables["cost_code"]]; } everything is working fine but databinding on the grid is not used. that is if u select a row from the datagrid it should change the values in the textbox that i have already added data bindings for. if u notice just selct a row from the grid, now the values in that row should show in your textboxes you have put below. Give a dataview for dataset pls help me to do this j o hn

    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