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 8284793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:14:26+00:00 2026-06-08T11:14:26+00:00

I have a DropDownList that’s databound to our SQL server with an ID, First

  • 0

I have a DropDownList that’s databound to our SQL server with an ID, First Name, Last Name. I’ve then added a GridView and Configured the Data Source to this

SELECT [ID], [fName], [lName] FROM [cb1] WHERE ([ID] = @ID)

Basically what I want it to do is when someone selects the first name from the dropdown it will pop up with the ID, First Name, and Last Name in the GridView.

The Problem is, when it’s loaded the DropDownList is empty and has no data, and the GridView is also missing.

Here is the markup.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                SortExpression="ID" />
            <asp:BoundField DataField="fName" HeaderText="fName" SortExpression="fName" />
            <asp:BoundField DataField="lName" HeaderText="lName" SortExpression="lName" />
        </Columns>
    </asp:GridView>
    <asp:DropDownList ID="DropDownList1" runat="server" 
        DataSourceID="SqlDataSource1" DataTextField="ID" DataValueField="ID">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:comboConnectionString1 %>" 
        DeleteCommand="DELETE FROM [cb1] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [cb1] ([fName], [lName]) VALUES (@fName, @lName)" 
        ProviderName="<%$ ConnectionStrings:comboConnectionString1.ProviderName %>" 
        SelectCommand="SELECT [ID], [fName], [lName] FROM [cb1] WHERE ([ID] = @ID)" 
        UpdateCommand="UPDATE [cb1] SET [fName] = @fName, [lName] = @lName WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="fName" Type="String" />
            <asp:Parameter Name="lName" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="ID" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="fName" Type="String" />
            <asp:Parameter Name="lName" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</p>
  • 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-06-08T11:14:29+00:00Added an answer on June 8, 2026 at 11:14 am
    Table Contains id,Name,department and age
    
    
     Department :
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource2" DataTextField="Department" 
                DataValueField="Department">
            </asp:DropDownList>
            <br />
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:demoConnectionString %>" 
                SelectCommand="SELECT DISTINCT [Department] FROM [profile]">
            </asp:SqlDataSource>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="id" DataSourceID="SqlDataSource3">
                <Columns>
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                        ReadOnly="True" SortExpression="id" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Department" HeaderText="Department" 
                        SortExpression="Department" />
                    <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:demoConnectionString %>" 
                SelectCommand="SELECT * FROM [profile] WHERE ([Department] = @Department)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownList1" Name="Department" 
                        PropertyName="SelectedValue" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
    
    Result:
    ![Result][1]
    
    
      [1]: https://i.stack.imgur.com/WrfP7.png
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET DropDownList control that retrieves the first and last name from
i have a dropdownlist that populates from the sql server database. populating the list
I have a dropdownlist that is being populated by a sql server, I am
I have a dropdownlist inside a gridview, that is loaded from a datasource when
I have a DataBound DropDownList that is loading fine, but i'd like to insert
I have a DropDownList that fires off some server-side databinding in its OnSelectedIndexChanged event.
I have a DropDownList that populates a GridView according to the selected value. I
Assume that I have a dropdownlist with 2 items and, by default, the first
I have a DropDownList with values that I get from a SQL database. Depending
I have a DropDownList that is filled with values returned by a SQL Query.

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.