TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dinesh Santhalingam
NA
737
368.7k
Load data table to array and return array using Jquery
Dec 28 2016 5:55 AM
[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..
Reply
Answers (
7
)
Enable checkbox when user clicks on Edit button (GridView)
how to show the all upload file on form in panel or images