开发者

DataRows not serializable in ASP.NET 2.0

开发者 https://www.devze.com 2023-02-17 05:46 出处:网络
My application uses DataRows and th开发者_如何转开发ey are not serializable. Is there a workaround for the same?Put them into a data table and that into a dataset. That should serialize correctly.You

My application uses DataRows and th开发者_如何转开发ey are not serializable. Is there a workaround for the same?


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


You could try to create a List<object>.

Then fill the List scanning DataRows, and serialize List.


        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();
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消