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. xml datagrid

xml datagrid

Scheduled Pinned Locked Moved C#
xmltutorialannouncement
6 Posts 2 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.
  • M Offline
    M Offline
    Mohammad Dabaan
    wrote on last edited by
    #1

    hi, i have datagrid filled from xml document, i want to make update, delete, add on the xml document through the datagrid, for example for the edit there will be a hyperlink located on the cloumn will direct me to another windows form and i will have the row data in controls on that windows form and i will make the edit from there, please i need a sample code for an urgent project

    Thanks alot Hamody

    M 1 Reply Last reply
    0
    • M Mohammad Dabaan

      hi, i have datagrid filled from xml document, i want to make update, delete, add on the xml document through the datagrid, for example for the edit there will be a hyperlink located on the cloumn will direct me to another windows form and i will have the row data in controls on that windows form and i will make the edit from there, please i need a sample code for an urgent project

      Thanks alot Hamody

      M Offline
      M Offline
      M J Jaya Chitra
      wrote on last edited by
      #2

      I tried the following code in my windows form which has a datagrid and i place it in the double click event of the datagridview Form2 f = new Form2(); f.val = dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[0].Value.ToString(); f.Show(); where val is a public variable declared in form2, i an haveing the first field as the primary key field so i referred it as cells[0]. and in the load event i placed the val to the textbox, now we got the key then using this value you can populate the form fields with the values from the xml file know. I am not sure about your expectation.

      Best Regards, M. J. Jaya Chitra

      M 1 Reply Last reply
      0
      • M M J Jaya Chitra

        I tried the following code in my windows form which has a datagrid and i place it in the double click event of the datagridview Form2 f = new Form2(); f.val = dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[0].Value.ToString(); f.Show(); where val is a public variable declared in form2, i an haveing the first field as the primary key field so i referred it as cells[0]. and in the load event i placed the val to the textbox, now we got the key then using this value you can populate the form fields with the values from the xml file know. I am not sure about your expectation.

        Best Regards, M. J. Jaya Chitra

        M Offline
        M Offline
        Mohammad Dabaan
        wrote on last edited by
        #3

        thnx, I did n some way else, but noww, do u know whow to delete from xml file, i deleted but i want to remove the node after deletion, for example if we have the following: Inida 5:55 Jordan 5:55 and if i want to remove the city where name = India, i want to make it as: Jordan 5:55 not as: Jordan 5:55 thanks for helping me;-) -- modified at 3:21 Monday 11th June, 2007 Thanks alot Hamody

        M 1 Reply Last reply
        0
        • M Mohammad Dabaan

          thnx, I did n some way else, but noww, do u know whow to delete from xml file, i deleted but i want to remove the node after deletion, for example if we have the following: Inida 5:55 Jordan 5:55 and if i want to remove the city where name = India, i want to make it as: Jordan 5:55 not as: Jordan 5:55 thanks for helping me;-) -- modified at 3:21 Monday 11th June, 2007 Thanks alot Hamody

          M Offline
          M Offline
          M J Jaya Chitra
          wrote on last edited by
          #4

          Have you find the solution and can you post me the code how you have tried to populate and delete it

          Best Regards, M. J. Jaya Chitra

          M 1 Reply Last reply
          0
          • M M J Jaya Chitra

            Have you find the solution and can you post me the code how you have tried to populate and delete it

            Best Regards, M. J. Jaya Chitra

            M Offline
            M Offline
            Mohammad Dabaan
            wrote on last edited by
            #5

            hello, realy no i havent got the solution up 2 this time, may u send me a code sample for adding a hyperlink to the datagat will redirect me to another windows form, and dnt worry after i will send u a full code sample

            Thanks alot Hamody

            M 1 Reply Last reply
            0
            • M Mohammad Dabaan

              hello, realy no i havent got the solution up 2 this time, may u send me a code sample for adding a hyperlink to the datagat will redirect me to another windows form, and dnt worry after i will send u a full code sample

              Thanks alot Hamody

              M Offline
              M Offline
              M J Jaya Chitra
              wrote on last edited by
              #6

              In .net 2005 This is a windows application I have adapted the following code in order to populate the datagridview from xml file DataSet ds = new DataSet(); ds.ReadXml(@"D:\myappl\Student.xml", XmlReadMode.Auto); dataGridView1.DataSource = ds.Tables[0]; While the datagrid is clicked then it mead=ns the user is tring to edit the record so that i can get the selected row and the selected rows first cell contains the primary key so i am passing that to the form 2 (edit form) as follows in that the constructor of the form 2 takes one string argument which is the primary key of the selected field passed from the form1 as follwos In form 1 private void dataGridView1_DoubleClick(object sender, EventArgs e) { MessageBox.Show("" + dataGridView1.CurrentCellAddress.Y); MessageBox.Show(dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[0].Value.ToString()); Form2 f = new Form2(dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[0].Value.ToString()); f.val = dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[0].Value.ToString(); f.Show(); } In form 2 public Form2(string value1) { InitializeComponent(); //getst he value and the value is stored in the txt box textBox1.Text = value1; DataSet ds = new DataSet(); //populates the dataset ds.ReadXml(@"D:\myappl\Student.xml", XmlReadMode.Auto); //assigns the primary key field ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns[0] }; //finds and retrieves the row for the key DataRow dr = ds.Tables[0].Rows.Find(textBox1.Text); //populates the value you can extends also textBox2.Text =Convert.ToString( dr[1]); } if the Datarow and DataSet object is global and if you give the following code it will be deleted. dr.delete(); ds.WriteXML(...) Please tell me whether this is working or not but keeping a linklabel inside a datagrid is not possible if it is a web application then you can do that by keeing the hyper link field in the gridview control and it is possible to hide the primary key also -- modified at 5:43 Monday 11th June, 2007

              Best Regards, M. J. Jaya Chitra

              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