Returning a gridview to the client side using a webservice

Here's what I'm trying to do.

I build a web page with a gridview on it and the gridview is databound to a datatable.

Using Javascript and Scriptmanager I call a webservice that adds a new row to my datatable and rebinding the gridview with my new dataset and retuning the HTML of the gridview to my page and refreshing my gridview with the new HTML.

Everything works great so far.

If I click on on of the items on my new row (such as a button) that does a postback .Net screams because it can't find a reference to this new button on that row. I understand why it's doing that, it's because .Net's resource file is not aware of the new row on the web page it's just aware of what it posted to the browser.

What I want is to be able to create a new gridview on the server-side send it to the client and display it using the client and have .Net aware that the gridivew has new rows, columns, etc... so when events are triggered on the .Net is aware of them.

 I'm trying to do it this way and not use the Updatepanel because when I use the updatepanel the round trip of the postback/redering the browser takes approx. 10 secs, while calling the webservice in Javascript and redering the received HTML of the gridview takes a fraction of a second this way.

 Any help, hints and suggestions are greatly apprecated.


Software Engineer, Analyst, Programmer, Documenter and waterboy.
0
LostFrenchManInTexas
2/27/2008 7:37:56 PM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

11 Replies
321 Views

Similar Articles

[PageSpeed] 3

ajax call page method is better than call web services because you need to rebind some data with gridview.


Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/28/2008 6:23:30 AM

Thanks for the reply, I am investigating right but could you enlighten me the ajax call page you are talking about.

Thanks appreciate the time


Software Engineer, Analyst, Programmer, Documenter and waterboy.
0
LostFrenchManInTexas
2/28/2008 9:11:19 PM

Please look this url for how to call page method using ajax

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx 

 

Hope it


Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/28/2008 9:25:43 PM

Please look this url for how to call page method using ajax

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx 

 

Hope it

can
Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/28/2008 9:25:45 PM

Please look this url for how to call page method using ajax

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx 

 

Hope it

can help y
Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/28/2008 9:25:48 PM

Please look this url for how to call page method using ajax

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx 

 

Hope it

can help you
Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/28/2008 9:25:50 PM

That's what I thought you were talking about.

Unless I'm missing something this does not give me what I want, it's a different way of doing what I'm currently doing.

What I need to do essentially is rebind my gridview with new data without having the full postback to the server (being that there's a lot of data being transfered and only port of my grid is being updated).


Software Engineer, Analyst, Programmer, Documenter and waterboy.
0
LostFrenchManInTexas
2/29/2008 12:26:43 AM

Base what I understand, you want to have a notification on the server (mssql), and when any changes, you will get new changed data, and after you receive the data, you want to add changes to your grid view without any postback, am I right?

On notification, part, you want to use javascript timer to listen the response from the server?


Could you descript more details please. 

 


Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/29/2008 1:02:22 AM

No that's not what I'm trying to accomplish, what I'm doing is this:

I have an editible gridview on my page.
I have a "New" button on my page and when I click on the New button I call a javascript function that either calls a PageMethod or does a CallBackEvent to the server, the callback event takes the original dataset/datatable and adds a new row and rebinds the gridview then I render the gridview to HTML and return the HTML to the client.

On the javascript side I display the HTML for the new gridview.

All of this works great.

My problem is that when I do a postback to the server the server doesn't see the new row and the data in it, it just sees the original 7 rows that it originally posted to the client.

Let's say that my grid has 7 rows when it is originally sent to the client, I click the "New" button and the grid now has 8 rows (because of the pagemethod)  but when I postback to save the data the Server only has 7 rows (it's not aware that there's an 8th row with new data in it).

I'm doing it this way using javascript and not using an updatepanel because the page is data heaving and when I use the updatepanel it takes about 10 seconds for the postback to complete while calling the PageMethod or CallBackEvent on the server takes a fraction of a second.

I'm assuming here that's because of the viewstate, the viewstate of the grid has not changed because what I sent back is just the gridview's rendered HTML.

Thanks, hope it clarifies a little what I'm trying to accomplish.

I just wish they had included a gridview in the Futures and not just the Datalist so we could databind on the client.


Software Engineer, Analyst, Programmer, Documenter and waterboy.
0
LostFrenchManInTexas
2/29/2008 1:42:06 AM

 Hi,

You are right,the viewstate is not changed.

I suggest you see http://codeplex.com/AjaxDataControls

Hope it helps.

Best Regards,
 


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
3/4/2008 11:06:13 AM

Thanks,

I've looked at the AjaxDataControls and they are limiting in the context of what I'm trying to accomplish.


Software Engineer, Analyst, Programmer, Documenter and waterboy.
0
LostFrenchManInTexas
3/4/2008 5:33:31 PM
Reply:

Similar Artilces:

Using AJAX and client side scripting with .NET objects?
I'm wanting to use client-side scripting and AJAX with some drop down boxes.  I can't seem to do this with server-side .NET objects... changing the runat tag doesn't do anything either.  How can I expose .NET server objects so that they are affected by java script and AJAX? Depends on what, exactly, you're trying to do with them.  If you just need access to the html properties (e.g. selectedValue), then you simply grab them as if they were their html equivilants (select element) in javascript.  If you want to pass custom properties back and forth (or any .Net property ...

connecting webservice using js/client side (not MS AJAX)
Hi all I have a dynamic button, that on submit need to call webservice I want to use style="behavior:url(Script/webservice.htc)" 1. how can I add dynamic style when creating it?SubmitRequestTextBox.ID = "SubmitRequestTextBox"; SubmitRequestTextBox.Text ="Submit"; SubmitRequestTextBox.Attributes.Add("OnClick", "GetWS()");   2.if I can't, I tried to put it in a div <div style="behavior:url(Script/webservice.htc)" > but I get an error msg Error 4 Validation (CSS 2.0): 'behavior' is not a kno...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

When To Use Client Side vs Server Side vs AJAX
Before AJAX, it was fairly clear to me where to draw the line between functionality best performed server-side vs client-side.  For example, database access and data processing is done on the server, and basic field validation and other UI stuff is done on the client.  But now with AJAX implemented through Atlas, the line is blured.  I know what can be done... but what is the optimal way to design a web application using Atlas (in terms of what functionality should be implemented server-side versus client-side versus Ajax)?  What is the prev...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

To display data we can use JSON return from WS, but what about edit a list of data and post back, what should be used on client side?
I remember there were a full client side demo back to the ATLAS age, I need edit a list of rows on client side, and post back when all done, What should I do in this case? thanks  Hi, The easiest method is using gridview in updatepanel. Please check out this link for more information: http://www.asp.net/AJAX/Documentation/Live/tutorials/UsingUpdatePanelControls.aspx Best Regards,Sincerely,Jin-Yu YinMicrosoft Online Community Support I use updatepanel in some places. It is good to save data without page post back. But what I need now is a way to do multi ...

Returning a DataTable from WebService using Ajax
Hi Everybody,I need to create a web service that is consumable on the client side.This web service should return a DataTable which I should consume on the client side.My question is how can it be done correctly. Can someone please show me an example of a web service consupmtion  that returns a DataTable, and how to retreive data from that  retruned DataTable on the client side. (using javaScript and the Microsoft Ajax Library).  Thanks in advance,                  &...

call webservice using javascript without using AJAX and webservice.htc?
HI,how can i call a webservice without using AJAX and Webservice.htc, using any protocols?Thanks.X you could skip using an AJAX framework and issue an xmlHttpRequest directlyhttp://en.wikipedia.org/wiki/XMLHttpRequestMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ Hi, thanks mbanavige.well, is there any disadvantage of using xmlhttprequest?and one more question can AJAX also work on other web servers than IIS like Apache? and is AJAX compatible with all browsers other than IE?how can i call a web servi...

how to consume a .net webservice using java client ?
Hi experts, I really need your help. I have create one .net webservice , it is really simple , the code is shown below .   [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { ...

Client vs. Server Side AJAX.Net
I am curious to know what the advantages and disadvantages are to using the client side declarative style AJAX controls vs. the server side.  I can't seem to think of too many reasons why I would go to the client side libraries when I can use all the power of ASP.NET (debugging, compiling, controls) and just wrap them in a UpdatePanel.   It also seems kind of counter productive to use the client side libraries because they don't utilize all the cool new developments of ASP.NET.  Am  I missing something?  Do the client AJAX libraries give you m...

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try http://www.w3schools.com/asp/asp_ref_filesystem.asp The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

Check if handler exists using AJAX Client-Side
Is there some way or me to find out if a handler has already been added to an object via $addHandler? I want to be able to check if an object already has a handler before I try and add the same handler (which gives an error). I don't see a way to do this in the client reference. Right now i am just calling $removeHandler within a try/catch before calling $addHandler, which works but is very hacky. Just don't use $addhandler. If you are adding an onclick for example - $addhandler(mybutton, onclick, myfunction) then skip it and just say mybutton.onclick = myfunction; This replac...

How to use client-side script(javascript) in .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script>  objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ......  }    szUrl = &...

Checking All CheckBoxes in a GridView Using Client-Side Script
Hi; I have  checkbox column in gridview and a checkbox in header gridview. i write down code: Dim checkbox As CheckBox = GridView2.HeaderRow.FindControl("HeaderCheckbox")checkbox.Attributes("onclick") = "ChangeAllCheckBoxStates(this.checked);"  For Each row As GridViewRow In GridView2.Rows Dim a As CheckBox = row.Cells(0).FindControl("CheckBox2") If row.RowType = DataControlRowType.DataRow ThenClientScript.RegisterArrayDeclaration("CheckboxIDs", String.Concat("'", a.ClientID, "'")) End IfNe...

Web resources about - Returning a gridview to the client side using a webservice - asp.net.ajax-discussion

webservices Articles, Posts, Blogs, Videos - Technorati
— Authority: The job consist in a PHP program that read a file, compose a message (email or sms) and call an API of email provider (Amazon SES) ...

Section: software:webservices
Wired.com © 2012 Condé Nast. All rights reserved. Use of this Site constitutes acceptance of our User Agreement (effective 3/21/12) and Privacy ...

Products - CrunchBase
Product profiles

App Search on Flickr - Application Sharing!
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Wikipedia:Press coverage 2005 - Wikipedia, the free encyclopedia
If you add an article, please cite both the title and the source. Note that if you're listing an article from a traditional press wire service ...

Entity–relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

Entity-relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

IT and Telecommunications Jobs in Melbourne Metro - MyCareer
Find IT and Telecommunications Jobs in Melbourne Metro on MyCareer. Fresh IT and Telecommunications Jobs posted daily. Free email alerts and ...

AWS Elastic Beanstalk: A Quick and Simple Way into the Cloud
Flexibility is one of the key principles of Amazon WebServices - developers can select any programming language and software package,any operating ...

How To Use the Amazon SDK for Android to Upload Photos to Amazon S3
This article demonstrates how to use the AWS SDK for Android to upload an image to Amazon Simple Storage Service (S3) from your mobile device ...

Resources last updated: 12/2/2015 5:43:45 PM