GridView Read Line by Line with foreach

2 posts, 0 answers
  1. Tom
    Tom avatar
    1 posts
    Member since:
    Apr 2012

    Posted 15 Apr 2012 Link to this post

    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
  2. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 19 Apr 2012 Link to this post

    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 >>
Back to Top