I am trying to associate a Dropdownlist with a Detailsview control on a page where the result of the second Dropdownlist depends on the first. I could associate one Dropdownlist with Detailsview, but if I add another Dropdownlist, the result of which depends on the first, then nothing will be displayed in the detail view unless you refresh the page.
So, is it possible to somehow publish the result of viewing the data automatically if the second drop-down menu is selected? I am currently studying this , but I could not get it.
Here is 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 greatly appreciated;)
Thanks in advance