Wednesday, March 21, 2012

Wrong EventName triggers. How come?

Hi

In the project I have two GridViews: master GridView1 and slave GridView2. The latter resides on the UpdatePanel with properties as follows:

AsynchPostBack ControlID=GridView1

EventName=SelectedIndexChanging

It works fine: if I select a row from GridView1, partial postback takes place and GridView2 re-populated

But! If I set GridView1.AllowSorting=true and click on any of GridView1 titles, it goes again with the partial postback! I don't have my GridView1.Sorting event handler in the list of UpdatePanel.ControlID but it acts as well it is.

How can I prevent a partial postpack in the case above? I need my page be sent as full old-way post back, when click on the GridView1 headers.

Hi Mabanza,

Mabanza:

But! If I set GridView1.AllowSorting=true and click on any of GridView1 titles, it goes again with the partial postback! I don't have my GridView1.Sorting event handler in the list of UpdatePanel.ControlID but it acts as well it is.

this sounds like you've let UpdatePanels UpdateMode on the default valueAllways. Please set it toConditional.


This relates to the children updates. Anyway, I did, no effect.

This boiled down to the follows, actually. I can not register the title (which is LinkButton on the server) as

RegisterPostBackControl(LinkButton);

It works the same wrong way - as partial post back.

How to register LinkButton for full postback?

Thanks.


May try use another way to go. Instead declaring the SelectedIndexChanging event as trigger, use in the SelectedIndexChanched event updatepanelsUpdate() method. eg.

void GridView1_SelectedIndexChanged(Object sender, EventArgs e){// Your logic here UpdatePanel1.Update();}

So you be sure, updatepanel only updates on changing the selected index from your gridview.


Good idea. But it does not suit me. I have

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest) andadd_beginRequest(StartRequest) hooked.

If I update panel on the server side, I won't be able to use that, right?

Thanks.


Mabanza:

If I update panel on the server side, I won't be able to use that, right?

not sure about that. To put it bluntly, i'm not a fan from javascriptCool Anyway.

Mabanza:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest) andadd_beginRequest(StartRequest) hooked.

I dont now where in the page lifecycle these events are fired, but for updating the gridview after page index changing, a roundtrip to the server is required. From my point, let the javascript beginRequest and endRequest events still active, give the UpdatePanel.Update method a try and look whats up on your page.

No comments:

Post a Comment