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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:16:13+00:00 2026-05-21T17:16:13+00:00

I’m trying to bind a Dropdownlist to a Detailsview control in a page where

  • 0

I’m trying to bind a Dropdownlist to a Detailsview control in a page where the result of the second Dropdownlist depends on the first one. I could bind a single Dropdownlist to a Detailsview but if I add another Dropdownlist where the result depends on the first one the details view wont show anything unless you refresh the page.

So is there any way I could post the result of the detailsview automatically if the second dropdown is selected? I’m currently studying this but I couldnt get it.

Here’s my sample code

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="LibrarySystem.Member.Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h3>
        Search</h3>
    <p>
        Choose a category
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="categoryDataSource" DataTextField="name" 
            DataValueField="categoryid">
        </asp:DropDownList>
        <asp:SqlDataSource ID="categoryDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>" 
            SelectCommand="SELECT categoryid, name FROM dbo.TblCategory">
        </asp:SqlDataSource>
    </p>
    <p>
        Choose a title
        <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
            DataSourceID="bookDataSource" DataTextField="booktitle" DataValueField="bookid">
        </asp:DropDownList>
        <asp:SqlDataSource ID="bookDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>" 

            SelectCommand="SELECT [categoryid], [booktitle], [bookid] FROM [TblBooks] WHERE ([categoryid] = @categoryid)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="categoryid" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            CellPadding="4" DataKeyNames="bookid" DataSourceID="bookdetailsDataSource" 
            ForeColor="#333333" GridLines="None">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
            <RowStyle BackColor="#EFF3FB" />
            <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <Fields>
                <asp:BoundField DataField="bookid" HeaderText="ID/ISBN" ReadOnly="True" 
                    SortExpression="bookid" />
                <asp:BoundField DataField="booktitle" HeaderText="Title" 
                    SortExpression="booktitle" />
                <asp:BoundField DataField="lastname" HeaderText="Author" 
                    SortExpression="lastname" />
                <asp:BoundField DataField="firstname" HeaderText="" 
                    SortExpression="firstname" />
                <asp:BoundField DataField="description" HeaderText="Description" 
                    SortExpression="description" />
                <asp:BoundField DataField="name" HeaderText="Category" SortExpression="name" />
                <asp:BoundField DataField="dateadded" HeaderText="Date added" 
                    SortExpression="dateadded" />
                <asp:BoundField DataField="quantity" HeaderText="No. of copies" 
                    SortExpression="quantity" />
                <asp:BoundField DataField="EmployeeID" HeaderText="Reserved by" 
                    SortExpression="EmployeeID" />
                <asp:BoundField DataField="reservedate" HeaderText="Reserved date" 
                    SortExpression="reservedate" />
                <asp:BoundField DataField="statusname" HeaderText="Status" 
                    SortExpression="statusname" />
            </Fields>
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:DetailsView>

Any help would be much appreciated 😉

Thanks in advance

  • 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-21T17:16:14+00:00Added an answer on May 21, 2026 at 5:16 pm

    You have to put your Dependent dropdown datasource in the parent template field. it will be look like…

     <asp:TemplateField HeaderText="Category">
          <InsertItemTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="categoryDataSource"
                            DataTextField="name" DataValueField="categoryid">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="categoryDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
                            SelectCommand="SELECT categoryid, name FROM dbo.TblCategory"></asp:SqlDataSource>
                        <asp:SqlDataSource ID="bookDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
                            SelectCommand="SELECT [categoryid], [booktitle], [bookid] FROM [TblBooks] WHERE ([categoryid] = @categoryid)">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="DropDownList1" Name="categoryid" PropertyName="SelectedValue"
                                    Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </InsertItemTemplate>
                </asp:TemplateField>
    
         <asp:TemplateField HeaderText="Title">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="bookDataSource"
                            DataTextField="booktitle" DataValueField="bookid">
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.