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

RadGrid Data to XML

1 Answer 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kathir
Top achievements
Rank 1
Kathir asked on 04 Sep 2009, 10:27 PM
Hi Telrik Team

is it Possible to Convert RadGrid Data to XML? i think there is no inbuild method to Export Into XML in rad grid.
please guide me to achieve this.

thanks

Regards
Kathir

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 08 Sep 2009, 08:11 PM
If you have a DataSet in your project that is populated from the data source that you have your Grid set to you can do this. I'm using a SQL data base and created a dummy DataSet called DataSet1 which is linked to databaseTable which is the table in my database. From here I just created a button which had this code-behind:

    protected void Button1_Click(object sender, EventArgs e) 
    { 
        databaseTableTableAdapter m = new databaseTableTableAdapter(); 
        DataSet1.databaseTableDataTable dt = new DataSet1.databaseTableDataTable(); 
        m.Fill(dt); 
        DataSet ds = new DataSet(); 
        ds.Tables.Add(dt); 
        ds.WriteXml(Server.MapPath("~/myFile.xml")); 
    } 

Here you see that I simply set up a TableAdapter and a DataTable and filled the DataTable. Once this is filled I added it to the DataSet. And DataSet objects have the function WriteXml that takes a string which is the file name of the .xml file you want to write to. Hopefully this helps!


Tags
Grid
Asked by
Kathir
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or