List Info

Thread: Chained DropDownLists and adding items.




Chained DropDownLists and adding items.
user name
2006-06-27 14:58:33
On Postback, are they tied to events?  If yes, then put them
in the
event handlers.  If not, call the correct method from the
page_load
method.  Even if they are handled by events, you should
still call a
different method from the event handlers since it seems you
are wanting
the same calls multiple times.

I hope this make sense.

Joe B.

-----Original Message-----
From: Robert Dickson [mailto:robertgdicksongmail.com] 
Sent: Monday, June 26, 2006 6:43 PM
To: aspnetaspadvice.com
Subject: [aspnet] Chained DropDownLists and adding items.


Hi folks,

I have a webform with a series of DropDownLists, the first
of which
controls
the content for the 2nd and 3rd. The trouble is I need to be
able after
the
postback call which binds those controls add about 4 items
manually to
the
2nd and 3rd DDL.

---Begin Code Snippet---
<aspropDownL
ist ID="ddlDivList" runat="server"
DataSourceID="sqlDDLDiv"
DataTextField="DivName"
DataValueField="DivID"
AutoPostBack="true"></aspropDownL
ist>
<aspropDownL
ist ID="ddlHome" runat="server"
DataSourceID="sqlDDLHome"
DataTextField="TeamName"
DataValueField="TeamName"></aspropDownL
ist>
<aspropDownL
ist ID="ddlVisitor" runat="server"
DataSourceID="sqlDDLVisitor"
DataTextField="TeamName"
DataValueField="TeamName"></aspropDownL
ist>

<asp:SqlDataSource ID="sqlDDLDiv"
runat="server"
    ConnectionString="<%$ ConnectionStrings:local
%>"
    SelectCommand="SELECT [DivName], [DivID] FROM
[AdultDiv]"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDDLVisitor"
runat="server"
    ConnectionString="<%$ ConnectionStrings:local
%>"
    SelectCommand="SELECT [TeamName] FROM
[AdultTeamStandings] WHERE
([DivID] = DivID)">
    <SelectParameters>
        <asp:ControlParameter
ControlID="ddlDivList" Name="DivID"
            PropertyName="SelectedValue"
Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDDLHome"
runat="server"
    ConnectionString="<%$ ConnectionStrings:local
%>"
    SelectCommand="SELECT [TeamName] FROM
[AdultTeamStandings] WHERE
([DivID] = DivID)">
    <SelectParameters>
        <asp:ControlParameter
ControlID="ddlDivList" Name="DivID"
            PropertyName="SelectedValue"
Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
---End Code Snippet---

Any suggestions how I can programatically add 4 items
manually to the
Home/Visitor DDL controls?

-- 
Thanks,
  Robert



--- List Sponsor ---
ASP & ASP.NET Web Hosting with 3 Months FREE & FREE
Setup!
ASP/.NET Hosting from a Microsoft Gold Partner supporting
ASP.NET
2.0/1.1, ASP, MS SQL 2005/2000 with DBO Access, Free
ASP/.NET Components
& more.  
Click Here for More Information:  http://www.disc
ountasp.net/aspadvice/


--- List Sponsor ---
ASP & ASP.NET Web Hosting with 3 Months FREE & FREE
Setup!
ASP/.NET Hosting from a Microsoft Gold Partner supporting
ASP.NET 2.0/1.1, ASP, MS SQL 2005/2000 with DBO Access, Free
ASP/.NET Components & more.  
Click Here for More Information:  http://www.disc
ountasp.net/aspadvice/

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )