I have tow diferent implementations for the same problem.
A gridview that is binded with some data and it has a select column that has a button. When the button click is fired I know in debug that the : sender.SelectedDataKey and sender.SelectedIndex have values that I use later.
But now I whant to use the ajax accordion control. I have an Accordion, and one Pane inside. Inside that pane I have a CollapsiblePanel (that uses the CollapsiblePanelExtender). And in that CollapsiblePanel I have my Gridview.
So, only when I click on the collapsiblePanel I want to get data from DB and bind it to the GridView. But it seems that using this methot the sender.SelectedDataKey and sender.SelectedIndex are Nothing (VB) when the PageIndexChanging fires!
This does not make any sense!
The GridView is the some on both implementations and EnableViewState=true
Thank you.
With the Accordion Panel being an Ajax control, it might be adding the Update Panel in there even though you did not add one to the page. Since the GridView is inside of an Ajax control, all the events that are being triggered by the GridView are going to be captured by Ajax. You might try making the GridView button clicks an Ajax callback as well.
I have run into this problem before where the controls inside of an Ajax Update Panel or an Ajax control; such as the Accordion Panel, fire the server side event handler, but because Ajax is involved, the values were stuck back on the client side.
be sure that your controls are in the same UpdatePanel, or update the various container UpdatePanels.
Related
I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him.
I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.
Is there any way to do the same without reloading of the page in a easiest way possible without using ajax control toolkit?
Additional info: the data for the dropdownlist is coming from the database, and some places it has to be all server side so i can't use javascript .
You can try this idea: http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx. I have not try it before but it seems logical.
you should go through updatepanel. Put all the controls inside a updatepanel which you want to show on selectedindexchanged event of the dropdownlist and write code behind on selectedindexchanged event of the dropdownlist accordingly. Hope this will help you...
This is what I'm trying to do with AJAX:
[DropDownList]
I have a DropDownList (not inside an UpdatePanel), populated by different Products to "Add" to the database.
[UpdatePanel #1]
Below, I have an Conditional UpdatePanel that listens for "SelectedIndexChanged" on the DropDownList, when that event is triggered it adds TextBoxes to a div "productForm" inside the UpdatePanel. It creates the Form according to the Product to add.
[Button]
Below the UpdatePanel I have a button that "should" submit the form above.
[UpdatePanel #2]
I have an update panel that listens for the event on Button "Click" event. I also have a div in the ContentTemplate that should post out data that was submitted from the "Add Product Form" in the first UpdatePanel.
The thing is, when I submit (and the Controls are still visible in the first UpdatePanel. It can't read the data from the TextBoxes becaus they aren't there. Also, if I try to add all this to the same UpdatePanel, the Controls disappear whenever I click the Submit button.
Any ideas how to make something similar work?
Without the code I can suspect that when you dynamically populate first div on dropdown selected index changed event, since its within update panel, viewstate is never made aware of new controls and on submit can't post them back to server.
I've had some bad experiences with update panel and never use it other than very simple scenarios. Try getting familiar with jQuery ajax. I would do what you want to do using jQuery and web methods.
I have a gridview inside a User Control which is being filled with data from a data source dynamically. One of the things I need to support is switching a non-data-bounded column from checkbox column to radiobutton column dybamically.
everything's cool when I create the columns for display, but when I try to add an event to the CheckChanged (or Click) of the columns, the events doesn't fire - Not at AsyncPostBack and not at full postback. Moreover, the AutoPostBack is set to true and the checkboxes and radiobuttons do fire the postback, but not their events.
I don't think it's relevant, but the loaded usercontrol is in a ModalPopUpExtender from AjaxToolkit and it is being showed at server side (using a dummy button, and a clickable button ith a server side event on click). Also, all the ModalPopUpExtender controls are inside of an UpdatePanel, and only the clickable button is not.
thanks in advance.
I'm not sure if it'll work using Ajax and ModalPopUpExtender but I think you need to handle it in the OnRowCommand event of grid.
So, the column of the checkboxes should have been added in a static sort of way (declare the column and the checkboxes/radiobuttons in html) - the page would register to the events, or needed to be registered in PreRender of the GridView, after acknowledging that they were added during an Ajax postback... the latter is the best way... but for those who have no time to debug, first way is better. see also:
http://www.codeproject.com/KB/custom-controls/asp-ajax-custom-controls.aspx
My understanding of the order of page events is this:
Page : Load
Control : DataBind (for a GridView or whatever)
Control : Load
Control : Clicked (for a Button)
Page: PreRender
Control : PreRender
(There are lots of others - but these are the ones I'm interested in)
The important thing to notice here is that the button's click event comes after the gridview's bind event. If the button causes a change to the data, the GridView displays the old data. I could rebind the control in the PreRender event, but that seems totally ugly.
This must be a very common pattern (a button that updates data). How do I put this together so that the GridView binds to the data after the Button click changes it?
The answer was in the Button Click event, after the data has been changed, call DataBind() on the page to cause the GridView (and anything else that needs it) to rebind. I didn't realise you could do that.
Thank you Ocdecio & Mufasa - I would mark your answers as helpful, but I got no rep yet.
ASP.NET does, by default, lots of binding and rebinding. Rebinding after a click event is normal.
The only reason the button click event comes after GridView bind is because you programmed your page to do that . I don't see any problem in binding the control in the PreRender event, in fact that is the only way to take action after a control event (such as Button onclick).
I have a panel on an aspx page which contains an UpdatePanel.
This panel is wrapped with both a PopUpControl Extender as well as a DragPanel Extender.
Upon initial show everything works fine, the panel pops up and closes as expected and can be dragged around as well.
There is a linkbutton within the UpdatePanel which triggers a partial postback. I originally wanted to use an imagebutton but had a lot of trouble with that so ended up using the linkbutton which works.
Once the partial postback is complete I can no longer drag the panel around.
I would love to hear suggestions on how to fix this.
Has anyone else encountered this problem?
What did you do about it?
Do you know of any other way to accomplish this combination of features without employing other third party libraries?
Take a look at when the drag panel extender and popup control extender actually extend your panel.
Chances are those extenders work on an initialization event of the page. When the update panel fires and updates your page the original DOM element that was extended was replaced by the result of the update panel. Which means that you now have a control that is no longer extended.
I don't really know of an easy solution to this problem. What will probably work is if you can hook into an event after the update panel has updated the page and extend the panel again.