Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3792754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:40:18+00:00 2026-05-19T12:40:18+00:00

I have a dropdown and a gridview. The gridview datasource is dependent on dropdown.SelectedValue

  • 0

I have a dropdown and a gridview.

The gridview datasource is dependent on dropdown.SelectedValue

The dropdown:

   <asp:DropDownList ID="DropDownListLoggedInUser" runat="server" autopostback="True"
                        DataSourceID="SqlDataSource3" DataTextField="Medarbejder" 
                        DataValueField="Medarbejder" 
        onload="DropDownListLoggedInUser_Load">
                    </asp:DropDownList>

It’s datasource:

               <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:EGWebtidConnectionString %>" 
                    SelectCommand="SELECT [Medarbejder] FROM [Sager] WHERE ([Medarbejder] IS NOT NULL)">
                </asp:SqlDataSource>

The gridview:

 <asp:GridView ID="GridViewSagsoversigt" runat="server" CellPadding="4" ForeColor="#333333"
                        GridLines="None" Style="text-align: left" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                        OnPreRender="GridViewSagsoversigt_PreRender" DataKeyNames="Sagsnr" EnablePersistedSelection="True"
                        SelectedIndex="0" OnSelectedIndexChanged="GridViewSagsoversigt_SelectedIndexChanged">

Its datasource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EGWebtidConnectionString %>"

                    SelectCommand="SELECT Sagsnr, Arbejskort, Adresse, Postnr, [By], Beskrivelse, Bemaerkning, Ansvarlig, Medarbejder FROM Sager WHERE ([Medarbejder] LIKE '%' + @Medarbejder + '%')">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownListLoggedInUser" Name="Medarbejder" 
                                PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>

When the page loads. The Gridview asks for Dropdown.SelectedValue, before Dropdown has fully loaded and set a SelectedValue. So SelectedValue returns "" and the Gridview shows nothing.

When I click on the dropdown and choose a name, it does a postback and it all works as planned.

So how can I make sure, that dropdown loads first and gridview loads second?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:40:19+00:00Added an answer on May 19, 2026 at 12:40 pm

    When you give control to the data source controls, you can’t explicitly control this. What you can do is explicitly call DataBind() on the gridview after the loading of the dropdown to rebind to the database again. You can also cancel the very first gridview load (if you want to eliminate a database call) by tapping into the Selecting event and setting e.Cancel = true.

    I don’t know if the ordering of DataSourceControls affects the priority of the execution… I don’t know if that is a factor too…

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Datagrid which looks as under <asp:GridView ID=dgTask runat=server Width=100% AutoGenerateColumns=False> <Columns>
I have a dropdownlist in my Gridview and I am binding a datasource to
In ASP.NET 4, I have a GridView, which contains a DropDownList in the asp:TemplateEdit
I have an ASP.NET GridView that has four columns. The first three are typical
I have a dropdownlist, and a Gridview where one of the columns is a
I have two dropdowns and a gridview (lstDivisions, lstDistricts, gridIncidents) in an asp.net page
I have a dropdownlist and the gridview and I want to bind the dropdownlist
I have a Gridview for which Dropdown list has to be added on the
I have dropdown list on my page. When I click on submit button, gridview
i have a gridview which has one of the columns as a dropdown. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.