xml datagrid
-
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
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 1private 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 2public 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, 2007Best Regards, M. J. Jaya Chitra