Saturday, July 24, 2010

how can i fill dataset values to javascript two diamentional array?

Try this:

Server-side code:

// Create the DataSet here:
DataSet yourDataSet = new DataSet();

System.Text.StringBuilder javaScript = new System.Text.StringBuilder();
DataTable dataTable = yourDataSet.Tables[0];

for (int i=0; i{
if (i == 0)
{
javaScript.Append("var yourArray = \n[\n");
}

DataRow dataRow = dataTable.Rows[i];

for (int j=0; j {
if (j == 0)
javaScript.Append(" [ ");

javaScript.Append("'" + dataRow[j].ToString().Trim() + "'");
if ((j + 1) == dataRow.Table.Columns.Count)
javaScript.Append(" ]");
else
javaScript.Append(",");
}

if ((i + 1) == dataTable.Rows.Count)
{
javaScript.Append("\n];\n");
}
else
{
javaScript.Append(",\n");
}
}
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ArrayScript", javaScript.ToString(), true);

Client-side code to test with:

.net core

 Sure, here are 50 .NET Core architect interview questions along with answers: 1. **What is .NET Core, and how does it differ from the tradi...