Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
7
Answers
Load data table to array and return array using Jquery
Dinesh Santhalingam
8y
312
1
Reply
[System.Web.Services.WebMethod]
public Array loaddata()
string
sql
=
"SELECT Name,Time,Inuse FROM table4"
;
using (SqlConnection
Connection
=
new
SqlConnection((@"Data Source)))
{
using (SqlCommand
myCommand
=
new
SqlCommand(sql, Connection))
{
Connection.Open();
using (SqlDataReader
myReader
=
myCommand
.ExecuteReader())
{
DataTable
dt
=
new
DataTable();
dt.Load(myReader);
Connection.Close();
DataView
dv
=
new
DataView(dt);
dv.RowFilter
= (("
Name
=
'ACVX'
"));
var
tableEnumerable
=
dv
.ToTable().AsEnumerable();
var
tableArray
=
tableEnumerable
.ToArray();
return tableArray ;
}
}
}
}
//Front End
<
html
>
<
head
/>
<
script
>
PageMethods.
loaddata
(LoadSucc, LoadFail);
function LoadSucc(obj) //obj is array returned from back end{obj-tablearray]
{
var
goog
= [];
goog
=
Object
.values(obj);
//I want load the obj into my array goog.
}
function LoadFail() {
alert("Data missing");
}
script
>
<
body
/>
html
>
I want to Load my data table content to array and return array to front end using page methods..Suggest me some ideas..
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
Enable checkbox when user clicks on Edit button (GridView)
how to show the all upload file on form in panel or images