开发者

DataRows not serializable in ASP.NET 2.0

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜