RedBottleSanitizer
RedBottleSanitizer

Reputation: 93

DataRows not serializable in ASP.NET 2.0

My application uses DataRows and they are not serializable. Is there a workaround for the same?

Upvotes: 2

Views: 1034

Answers (3)

stefano m
stefano m

Reputation: 4244

You could try to create a List<object>.

Then fill the List scanning DataRows, and serialize List.

Upvotes: 2

aistrong
aistrong

Reputation: 1

        DataTable dt = dataRow.Table.Clone();
        dt.ImportRow(dataRow);
        dt.AcceptChanges();

        string xml = string.Empty;
        using (var writer = new StringWriter())
        {
            dt.WriteXml(writer);
            xml = writer.ToString();
        }

Upvotes: 0

StingyJack
StingyJack

Reputation: 19479

Put them into a data table and that into a dataset. That should serialize correctly.

Upvotes: 3

Related Questions