i'm trying bind dropdownlist detailsview control in page result of second dropdownlist depends on first one. bind single dropdownlist detailsview if add dropdownlist result depends on first 1 details view wont show unless refresh page.
so there way post result of detailsview automatically if second dropdown selected? i'm studying this couldnt it.
here's 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 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 dbo.tblcategory"> </asp:sqldatasource> </p> <p> choose 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] [tblbooks] ([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 appreciated ;)
thanks in advance
you have put dependent dropdown datasource in parent template field. 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 dbo.tblcategory"></asp:sqldatasource> <asp:sqldatasource id="bookdatasource" runat="server" connectionstring="<%$ connectionstrings:librarysystemconnectionstring %>" selectcommand="select [categoryid], [booktitle], [bookid] [tblbooks] ([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>
Comments
Post a Comment