Saturday, March 24, 2012

Working with a returned DataSet

After I returned a DataSet through a WebMethod, how do I work with it?
I didn't understand this part of Atlas.

1. I loop through this DataSet creating new dynamic tables, trs and tds to display this data?

2. Can I bind it to an asp.net control like a GridView and it willautomatically update the control via JS, just like it happens on theserver side binding?

I tried looping through the returned DataSet but it has some weirdfunctions and attributes not quite like a DataSet... so... how do I useit?

function RetInfo(id)
{
PageMethods.RetDataSet(id,OnComplete);
}

function OnComplete(ds)
{
//do something with the DataSet
//ds.Tables (?)
}

[WebMethod]
public DataSet RetDataSet(int id)
{
DataSet ds = new DataSet();
//...get data from the database
return ds;
}

I recommend you check out this writeup by Garbin:

http://aspadvice.com/blogs/garbin/archive/2006/03/05/15591.aspx


You might want to review this page as well:

http://atlas.asp.net/docs/atlas/doc/data/default.aspx#datatable


Thanks man, that's exactly what I was looking for.

Just two more questions though:

1. If use that xml binding, can I use a PageMethod instead of a webservice as DataSource?

2. And, is a PageMethod considered a WebService? Will it have the same security issues as WebServices do (like being accessible to anyone)?

Thanks!

No comments:

Post a Comment