How can I get the datasource to refresh itself - asp: sqldatasource wizard

Posted on 2010-11-29
Last Modified: 2012-05-10
I am trying to use the asp: SqlDataSource wizard to populate my drop down list.  My drop down list gets populated based upon what another drop down's selected value is.  Now, during the page load, the drop down list gets populated correctly.  But, when the user changes the selected value of the 2nd drop down, (which is what the first drop down list uses the selected value to bring back the records) the first drop down list does not populate new data.  How can I get the databind to fire off automatically again on selected index change of the 2nd drop down list?

I have attached my sqldatasource code that is attached to my first drop down list.
<asp:SqlDataSource ID="sqlDSLTLCarrierList" runat="server" 
                                        ConnectionString="<%$ ConnectionStrings:ProcessShipperConnectionString %>" 
                                        SelectCommand="SELECT [cname] FROM [LTLCarriers] WHERE ([plantid] = @plantid)">
                                            <asp:ControlParameter ControlID="DDLPlants" Name="plantid" 
                                                PropertyName="SelectedValue" Type="String" />

Open in new window

Question by:Bran-Damage
  • 4
  • 3

Expert Comment

ID: 34234398
is the first dropdown's autopostback property set to true?

Author Comment

ID: 34234500
No, I do not have the first one set to true, the second one is however.

Expert Comment

ID: 34234743
try using Text instead of SelectedValue for PropertyName
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 34239258
That did not work.  I'm going to try an explain this a little more in depth.

when the page loads, I have a drop down box that gets populated with location IDs.  Then another drop down box, (this one has the sqldatasource attached with the where clause being the locationid drop down box selectedvalue).  The location Id drop down box gets set to a default location, and everything I do on the screen populates correctly, even the sqldatasource drop down list.  Now, when someone changes the locationid drop down, there is a post back that happens, but the sqldatasource drop down list has old data in it from the previous locationid and no new data with the new selected location id.


Expert Comment

ID: 34239483
Here is an example similar to what you are looking for.  It uses a drop down, gridview and 2 sqldatasource controls.


Accepted Solution

Bran-Damage earned 0 total points
ID: 34534765
I have gone another route with this.  None of these solutions worked for what I am trying to deal with.


Author Closing Comment

ID: 34618218
Went another route.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question