Bind Data to Repeater control using JSON string from server side
Bind Data to Repeater control using JSON string from server side
Roopa25
Posts: 1Questions: 0Answers: 0
Hi,
I need help with binding repeater control on my aspx page with JSON data. I am able to convert my data table to JSON string. Now i want to bind my repeater control with the result.
Code used to convert datatable to JSON string-
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List rows = new List();
Dictionary row;
foreach (DataRow dr in firstTable.Rows)
{
row = new Dictionary();
foreach (DataColumn col in firstTable.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
string str = serializer.Serialize(rows);
code on my aspx page -
$('#tblOscarNominees').dataTable({
"sScrollY": "200px",
"sDom": "frtiS",
"bDeferRender": true,
"bServerSide": true,
"sAjaxSource": "/Table5.aspx.cs" (or save the data to a txt file and add path here)
});
I have item template on repeater control as -
<%# Eval("id") %>
..............
Please let me know how to bind data from JSON to the repeater control. If possible please provide a sample solution for the same.
Thank you.
I need help with binding repeater control on my aspx page with JSON data. I am able to convert my data table to JSON string. Now i want to bind my repeater control with the result.
Code used to convert datatable to JSON string-
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List rows = new List();
Dictionary row;
foreach (DataRow dr in firstTable.Rows)
{
row = new Dictionary();
foreach (DataColumn col in firstTable.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
string str = serializer.Serialize(rows);
code on my aspx page -
$('#tblOscarNominees').dataTable({
"sScrollY": "200px",
"sDom": "frtiS",
"bDeferRender": true,
"bServerSide": true,
"sAjaxSource": "/Table5.aspx.cs" (or save the data to a txt file and add path here)
});
I have item template on repeater control as -
<%# Eval("id") %>
..............
Please let me know how to bind data from JSON to the repeater control. If possible please provide a sample solution for the same.
Thank you.
This discussion has been closed.