in the page load I have datatable.
I want to fill the datatable to an array in javascript
for example:
c[1560]="drafd"
c[3250]="drff"
c[115]="ddrff"
how can I do it
thanks!
Printable View
in the page load I have datatable.
I want to fill the datatable to an array in javascript
for example:
c[1560]="drafd"
c[3250]="drff"
c[115]="ddrff"
how can I do it
thanks!
Loop through each row in your datatable, creating a string as you go
Code:System.Data.DataTable dt = new System.Data.DataTable();
string strJSArray = "";
for(int i = 0;i<dt.Rows.Count;i++)
{
strJSArray += "c[" + i.ToString() + "]=\"" + dt.Rows[i][4].ToString() + "\";";
}