Results 1 to 2 of 2

Thread: datatable to array in javascript

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    194

    datatable to array in javascript

    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!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: datatable to array in javascript

    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() + "\";";
    			}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width