This is a migrated thread and some comments may be shown as answers.

GridView Read Line by Line with foreach

1 Answer 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 15 Apr 2012, 06:11 AM
Hi,
I use the telerik GridView and read datas from a XML in this. Now I will write an XML from the GridView. I will read it same as a normaly windows list view element so this code i used for this:
foreach (ListViewItem lvi in lvPending.Items)
                {
 
                    writer.WriteStartElement("transaction");
                    writer.WriteStartElement("eventId");
                    writer.WriteString(lvi.SubItems[0].Text);
                    writer.WriteEndElement();//eventID
                    writer.WriteStartElement("orderNumber");
                    writer.WriteString(lvi.SubItems[1].Text);
So my question how can I read this with a teleric grid view?
foreach (GridDataItem item in RadGrid1.Items)
{
   
}

doesn´t run. I got the error:The type or namespace name 'GridDataItem' could not be found (are you missing a using directive or an assembly reference?)  

Thanks for help
Thomas

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Apr 2012, 06:50 AM
Hi Tom,

Thank you for writing.

For you scenario I will suggest that you read the XML into a DataSet and use its table as DataSource for RadGridView. Then, when you want to save the data back to the XML, again use the DataSet WriteXml method.

More information regarding binding RadGridView to XML can be found here:  http://www.telerik.com/help/winforms/gridview-populating-with-data-bind-to-xml.html 

I hope that you find this information useful. Let us know is you have any other questions.
 
Regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Tom
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or