Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How To Split String and Display result on DataTable

$
0
0

Good day all, I have this string 

[{"service":"text","reference":"5dcfc526b883867e194e55202erdda8b2812","status":"DELIVERED"},
{"service":"text","reference":"7f8924de616129f2ac6ec1c85ddd5438d9","status":"DELIVERED"},
{"service":"text","reference":"02c17e2ccbf04f6116e3758a129dwrg30c73","status":"DELIVERED"}] // This is my datatable DataTable table = new DataTable(); DataColumn ID = table.Columns.Add("ID", typeof(string)); DataColumn Status = table.Columns.Add("status", typeof(string)); string source = rfs; string[] lines = source.Split(new[] { "\r\n", "\r", "\n"}, StringSplitOptions.None); foreach (var line in lines) { string[] a = line.Split('"'); DataRow row = table.NewRow(); row.SetField(ID, a[7]); row.SetField(Status, a[11]); table.Rows.Add(row); } dy.DataSource = table; dy.DataBind(); I am able to get the first role and display the result on datatable which is this //"service":"text","reference":"5dcfc526b883867e194e55202a8b2812","status":"DELIVERED" I want to display all the records ...But i am able to display only one record.. Where do i get it wrong


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>