this is my second option regarding my first question I did a lot of searching in google and tried it for a couple of times. Do you think its possible to populate a gridview without any postback from a dropdownlist?
Use update panel and script manager. Change properties of update panel Update mod conditional. After you can call when you want "updatepanel.Update()" or select your trigers and it ll do it automaticly.
No. You need postback in some form traditionally or using AJAX. These kinds of things happen in the server and that is why you need postback. Or you can use extensive Javascript.
You can use JavaScript and draw the whole gridview since a gridview is a table with columns and rows.
Related
I am working on a project in which on selecting a drop down list item the values from the database should appear in the respective two text boxes.
But, alongside I am placing an image which is actually getting created based on the two values. Now on selecting the next dropdownlist item there is a page refresh and the placed image dissapears.
How to I avoid the page refresh keeping in mind that the fields from the database must get displayed on the page in the two fields on select of drop down list.
Kindly help!
thanks...
In my case, there exists a table in which there are two halfs, the left has text boxes n a button n to the right side of the table the image appears.
If you are using ASP.NET WebForms, you could wrap the controls which you only wants to post back inside an UpdatePanel.
Alternatively, remove AutoPostBack="true" from your DropDownList, and use javascript/jQuery AJAX to perform your database request.
Disable autopostback.
<asp:DropDownList AutoPostBack="false" ... />
Without the slightest piece of code, this will be hard to answer.
To prevent default behavior in javascript, there is this method
e.preventDefault();
Where e is your event.
Your issue is to preserve the values fetched from DB.
The easiest and safest way is to store the values fetched from database into hidden fields. This way when your page postbacks the values persists and you can use them as you wish.
Happy Coding!!!
Is there a way to have autopostback enabled and not have page refresh (thereofre scrolling back to the top) when a dropdownlist changes for example?
I have a few dropdownlists and the values in the subsequent ones need to change based on what is picked in the upper ones.
Whats the best way to do that? Each DDL is populated from the DB.
Use an update panel to accomplish this. A full overview is provide here You add items to the panel that you need to post back and only that part of the page postbacks.
You could maintain scroll position between postbacks pretty easily
http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx
you can put all ddl into updatepanel,and then page will not postback itself.And your ddl can be rebind without needing a full page postback.
another option is to use cascading dropdown,there is a sample in asp.net ajax toolkit samples.It uses webservices for databinding.This methot is better than using updatapanels,but its little hard to implement.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx ,check this example.
Us Jquery AJAX OR Simply Use ASP.net UpdatePanel Control
I am using 1 main update panel which contains Search criteria and a Search button.
In side this main update panel I am using 4 update panels.
These four update panels fetching search results from different 4 SQL quires. Currently I did this.
But my question is, currently the page will come to display after fetching all all 4 update panels.
But I needed, If one panel get full record that one panel will come to display. then next filed panel.... Like this.
Please help me.
If I understand you correctly, you want the inner UpdatePanels to update consecutively when the outer UpdatePanel is updated? If this is correct then by default, all nested UpdatePanels will be updated when the parent UpdatePanel is updated.
It sounds like it would be better to not have the outer UpdatePanel, set a trigger on (inner) UpdatePanel 1 to update when search is clicked, set a trigger on UpdatePanel 2 to update when UpdatePanel 1 updates, etc, etc.
Alternatively, you could implement AJAX calls to Page Methods or Web services to populate the contents of the UpdatePanels and do away with the UpdatePanels instead.
Jason I think you problem may stem from the fact that you have nested your 'SQL' UpdatePanels within the 'Search' Update panel. You may want to separate them and look at AsyncPostBack triggers to get all four to fire once you have entered search critera.
The question is not clear, but you can check the results of the four queries in the Selected event of each of the DataSourceControls you use (I suppose you do), and if you find a record in a set displayed in the previous set, then apply your custom adjustment.
A side question: why using 4 update panels while the whole 5 panels are triggered by the same source (the search button)?
I know there is a similar problem on this forum, but the solutions did not really work for me. I am populating form controls with fields from a few different data sources, and the data shows up great.
I have an ImageButton control, which has an OnClick Event set to grab all of the data from the form. Unfortunately, when I click the button, it seems as though the page is reloading first, and THEN is executes the OnClick call. The data that was hand-entered, or hard-coded seems to be pulled fine from the controls it was entered in, but anything that was pulled from a datasource is not able to be read. Any ideas. this is the last hurdle in a project that I have been working on for 6 months.
Are you talking about drop downs or gridviews? When are you binding data, on page load?
Good design will have you bind your data upon page load but only in
if(!isPostBack){
dropdown.databind()
gridview.databind()
}.
Otherwise it will rebind every page load. If its not reloading you can get selected values from those controls if thats what your looking for.
An alternative is to set your data source and databind in your aspx page with a datasource object. That automates the above automatically.
Have you enabled viewstate on your controls? Posting code samples would go a long way to helping solve your issue.
When you click on a bottom in asp.net at first all the page Events take place like Page_Load and ... and then the event happens ( in this case Click).
But because everything is loading again, I think that you have a !isPostback in your code that you use to bind the data, you should remove that in order to get your data every time.
Or if it is not the solution please post some code and more description for the problem
Actually, it is hiddenfields, dropdowns, labels, and textfields. I just tried doing the binding in the init, and the load, but no dice. When I tried binding it on !isPostBack only, none of the fields showed up.
I think one of the main problems is that the dataset I am getting is from a method call to an API. I receive the data fine, but it comes in programmatically, then I have to do all of the control-setting programmatically as well. Would you like to see the code for ideas? Thank you for helping, no one is working today!
Jason
Ok, so there has to be a way to do this... no? If not I'd love some ideas.
I have two repeaters and an image inside an update panel along with some AJAX dropdowns with link buttons to the left. I want to update the data inside the update panel as fast as possible as values are selected from the dropdowns.
What do you think would be the best way to update the data? The repeaters are populated by objects, so if I could just filter the objects by some properties I could end up with the correct data. No new data from the server is needed.
Anyone have some ideas?
As far as I know, it is not easy to get just Data and data-bind the repeater on the client side. But, you might want to check this out.
Wrap only the repeater you want to rebind with an update panel of its own. The only viewstate transferred when doing this is the portion inside the update panel. You may have to play around with the triggers and update mode of the panels to get everything to play nicely.
Another option is instead of using repeaters, serialize your objects into XML and then write a page method that returns an html string of your transformed data using xsl. Then client side call your path method and update the DOM as appropriate.
A third option is to use use a service reference/page method to return JSON objects and update the DOM manually.
http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXWebServicesTutorials.aspx
Good luck! I have done all 3,
If your data is already rendered to the screen, you can access the dom and manipulate the dom and hide/remove the ones you want. I've done this with jquery, but the same should be possible with ASP.NET Ajax library.