WebService Linq ToList() Jquery

dingir
dingir used Ask the Experts™
on
I have a webservice that result a list of data.

I would be glad of a fully sample of how to create a simple task to load that ata to a gridview.
I know that the ajax-part isn't correct at all, but that's a part of the help I need.
The result is of course that the gridview will be fully loaded with the result of the webservice through ajax.

Thank's in advanced,
Webservicefile..
    [WebMethod(Description = "Sub Affiliates Information")]
    public P Listing()
    {
        net.DataContext db = new net.DataContext();
        P p2 = new P();
 
        var sa = from n in db.Users
                 where n.uid == 2323232323
                 orderby n.Username descending
                 select n;
 
        foreach (var su in sa)
        {
                 ....
        };
 
        p2.ReturnOk = true;
        return p;
    }
 
    public class P
    {
        public bool ReturnOk;
        public string x;
        public string y;
        public string z;
    }
 
 
And the clientside...
        <asp:GridView runat="server" ID="GridView1">
        </asp:GridView>
 
<script type="text/javascript">
    $(document).ready(function() {
       ajax("webService/name.asmx/P", "{'qyear':'" + year + "','qmonth':'" + month + "'}", fnc);
    });
   function fnc(msg) {
       $("#GridView1").html(msg.d.x);
</script>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you are intent on using the GridView, you are likely to find this easier to do if you put your GridView inside an UpdatePanel (.NET 3.5, or part of the MS Ajax Toolkit) and use a partial postback to repopulate your data.

If you are going to stick with JQuery's AJAX support, you may have more joy creating an IHttpHandler to fetch the data and return it as JSON or XML.  There are a number of JQuery grid plugins that can repopulate themselves with JSON/XML data.  You'll find many on the JQuery website.

J.

Author

Commented:
i'm not at all stucked on using a gridview! all possibilities are welcome.. thank's for answer!
http://dreakmore.info/tgrid/ might be a nice option.  I've not used it but I believe it can retrieve data from the server by requesting a URL and parsing the results.  You would make an IHttpHandler that accepts the parameters that tgrid provides and can send your results in the format tgrid expects.

There's not much documentation on tgrid it at the moment, but the developer's email is on the site above.  They might be be able to help with the expected output format.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial