ラベル webservice の投稿を表示しています。 すべての投稿を表示
ラベル webservice の投稿を表示しています。 すべての投稿を表示

2012年3月26日月曜日

Return a DataTable with Webservice and Bind via JavaScript

I am using a Webserivce method that returns a DataTable and in JavaScript I have this:

function pageLoad() {
ret = Dashboard.FetchQuadOne(OnCompleteOne, OnTimeOut, OnError);
ret = Dashboard.FetchQuadTwo(OnCompleteTwo, OnTimeOut, OnError);
}

function OnCompleteOne(result) {
document.getElementById('div1').innerHTML = result;
}

If I have my Webservice method, FetchQuadOne return a DataTable, how can I bind that to a GridView using JavaScript? Or is there a way to do this in the code-behind of my .aspx page? I guess I could just build an html table in my webservice method and return that, but it would be mugh each easier to bind the DataTable to a GridView.

I don't see how this could work, a DataTable is a .NET specific object. Javascript has no knowledge of how to consume that or for that matter any knowledge of how to bind to a .NET Datagrid. You could return xml or JSON and bind to some other data structure using XSL or roll your own.

Yeah, that is what I was afraid of. I thought maybe there would be someone way to put the JavaScript in the code-behind page and somehow bind the DataTable to a GirdView. I wanted all the built-in features of the GridView, like sorting and formating. O- well. I just wanted to make sure it wasn't possible before I head down an ugly road of building the table on the fly with the data.

Thanks.


Hi,

I think this article ofKazi Manzur Rashid can help you:http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

This article will show you how to create an AJAX Grid and a generic pager, which mimics the built-in GridView control on the client side.

Best Regards,

2012年3月24日土曜日

return straight xml rather than dataset

i just deployed my first webservice. it works perfectly. now, however, i am trying to use it in livecycle and i think livecycle can't handle the dataset which is returned by my webservice. how can i convert my dataset into straight xml?

DataSet ds = new DataSet()
StringWriter writer = new StringWriter();
ds.WriteXml(writer);
return writer.ToString();

Returning a Collection when calling a Webservice from the Client

Hi everybody.

I want to return some kind of collection of objects when calling a Webservice from the Client
I saw a couple of tutorials and how to's how to return a complex type in this situation.

What i did not find is information how to pass a list of objects back to javascript.
i tried returning an array of string or a generic list of string, but then i can't process it on ClientSide.
Maybe i declare my callback function wrongly in javascript.

Does anybody have samples for this or any input?

Thanks! Martin

Hi Martin,

I'am returning some object arrays from server to JS, and processing this in client-side, here some pseudo:

Server Side:

[WebMethod]public MyObject[] GetMyObjectArray(){//...some fancy codereturn(myObjectArray);}Client-Side//The CallMyNameSpace.GetMyObjectArray(Process_OnComplete, onTimeout);function Process_OnComplete(result){for(var i=0; i < result.length; i++){
alert(result[i].MyObjectProperty);
 }

}

hope this help


Hello kpeguero!
Thx a lot for your reply!

Seems i was just a victim of Caching.
But your sample helped me to be sure that i'm on the right way with my attempts. ;)

It works fine now wether i'm using arrays or generics... cool :)

Regards Martin