This is a migrated thread and some comments may be shown as answers.

RadGrid a Button and AJAX

6 Answers 174 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
SDI
Top achievements
Rank 1
SDI asked on 20 Dec 2011, 03:14 AM
I have a RadGrid that is read-only. User clicks a "Create" button and it creates a new record to the grid with some default values already in place. I placed a ajaxManager and a ajaxPanel on the page. The manager points to the button as initiating the request and the grid as being updated by the request from the button. The button has "onClick=" to the server-side click event which adds a record for the grid. But this is not being hit first. Instead "NeedDataSource" of the grid then the "_Click" event (which has the rebind in it too), lastly the "PreRender" of the grid. Sadly the grid does not reflect the added record. It does pick up the last one when I click the "Create" again, due to the rebind grabbing the previous addition the the table.

How can I avoid this? Why is the "NeedDataSource" being hit first before the actual button whom requested the call?

Thanks
SDI

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Dec 2011, 01:26 PM
Hello SDI,

Please have a look into the following documentation, which explain about ajaxifying Controls Wrapped in RadAjaxPanel and Added to RadAjaxManager Settings

RadControls for ASP.NET AJAX Documentation

Please paste your complete code if it doesn't help.

-Shinu.
0
Accepted
Tsvetina
Telerik team
answered on 20 Dec 2011, 01:59 PM
Hi,

Confirm that you do not have ViewState disabled for the grid. In this case the control fires NeedDataSource before the postback event:
RadGrid Event Sequence

Also, does the scenario work correctly with AJAX disabled?

Best wishes,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
SDI
Top achievements
Rank 1
answered on 20 Dec 2011, 05:31 PM
Yes, the EnableViewState=True on the Grid, but FALSE on the MasterView, it was hidden at the end of the list Data/ClientKeyNames - DOH! Okay that is fixed and is hitting the events properly, thanks for the lead!

However now something is happening with the AJAX Panel, it removes itself after the first update, but now does not hide itself after the second update. So, I click the Create button and it works great, then I click it again and the AJAXPanel stays over the grid.

The AJAXPanel never goes away after the second button click...

<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" EnableViewState="True" />
  
Thanks!
SDI
0
SDI
Top achievements
Rank 1
answered on 22 Dec 2011, 04:19 AM
I use a Rad Button and the sever side code gets hit the first round, the ajax panel shows and then its gone and new record appears in the grid. I click the button again and the ajax panel shows but it doesn't go to the server.

<telerik:RadButton ID="RadButtonAddProgram" runat="server" Text="Create" OnClick="RadButtonAddProgram_Click"  />

Is there another setting I need?

EDIT: It DOES hit the server code again, it is working as it should, but the ajax panel will not hide itself. Why not, do I have to code for it to be removed?

Thanks
SDI
0
Accepted
Tsvetina
Telerik team
answered on 22 Dec 2011, 12:37 PM
Hello,

Try running your page with script debugging enabled and check whether you get any client script errors. What you describe is not expected behavior, unless you have custom code for showing and hiding the loading panels. It is possible that you get multiple AJAX request breaking each other's functionality.

Let us know if you observe any client errors and provide as much detail about them as possible.

Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
SDI
Top achievements
Rank 1
answered on 23 Dec 2011, 04:16 AM
Yes, it seemed to be invalid data coming back and erroring out in the script which was causing the ajax to fail. 

Thanks!
SDI
Tags
Ajax
Asked by
SDI
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tsvetina
Telerik team
SDI
Top achievements
Rank 1
Share this question
or