Ajaxpro obtains Dataset

Source: Internet
Author: User

Suppose there is such a method in index. CS,

[Ajaxpro. ajaxmethod]
Public dataset getdataset ()
{
Dataset DS = new dataset ();
Sqldataadapter sap = new sqldataadapter ("select * from jobs", DB. getconn ());
Sap. Fill (DS, "Jobs ");

Return Ds;
}

How can we set the value at the front-end,

Function getdata ()
{
// Obtain the returned data. The current status is of the object type.
VaR OBJ = _ default. getdataset ();
// Obtain the data set
VaR DS = obj. value;
// The subsequent operations are similar to those in time. Note that the number of rows is the Length attribute.
VaR Len = Ds. Tables [0]. Rows. length;
// Obtain the data table in the dataset
VaR TBL = Ds. Tables [0];
// Prepare to display dataset in a table
VaR tblhtml = "<Table border = 1> ";
Tblhtml + = "<tr> ";
// Similarly, the column number attribute here is also Length
For (var j = 0; j <TBL. Columns. length; j ++)
{
// Obtain the column header
Tblhtml + = "<TH>" + TBL. Columns [J]. Name + "</Th> ";
}
Tblhtml + = "</tr> ";

// Specific data
For (VAR I = 0; I <TBL. Rows. length; I ++)
{
Tblhtml + = "<tr> ";
For (var j = 0; j <TBL. Columns. length; j ++)
{
// Obtain data in each column of each row
Tblhtml + = "<TD>" + TBL. Rows [I] [TBL. Columns [J]. Name] + "</TD> ";
}
Tblhtml + = "</tr> ";
}
Tblhtml + = "</table> ";
// Obtain the front-end Div
VaR divpro = Document. getelementbyid ("divpro ");
// Fill Div data
Divpro. innerhtml = tblhtml;
}

At this point, the dataset is displayed on the front-end.
Http://www.cnblogs.com/xiangpiren/archive/2007/08/26/869920.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.