Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
Binding two data columns to one DropDownList
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="cw bebop, post: 4099608"] Is there a way to bind two columns from a table to one DropDownList? Below I have the column ["DNAME"] databound to DropDownList1 and would like to also have the column ["LOC"] bound to the same DropDownList1 from the Dept table. Can this be done? Have a dropdownlist with DNAME and right next to it LOC in the same Dropdownlist. Any suggestions would be appreciated. Thanks. bebop Code I'm using: HTML: <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px" runat="server" Text="Button"></asp:Button> <aspropDownList id="DropDownList1" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 40px" runat="server" Width="320px"></aspropDownList></form> C# Code behind: private void Button1_Click(object sender, System.EventArgs e) { OracleDataAdapter myda = new OracleDataAdapter("select * from dept","server=localhost;user id=scott;password=tiger"); DataSet ds = new DataSet(); myda.Fill(ds,"DEPT"); //DataSet ds2 = new DataSet(); //myda.Fill(ds2,"DEPT"); DropDownList1.DataSource =ds.Tables[0]; DropDownList1.DataTextField =ds.Tables[0].Columns["DNAME"].ColumnName.ToString(); //DropDownList1.DataTextField = ds2.Tables[0].Columns["LOC"].ColumnName.ToString(); DropDownList1.DataValueField =ds.Tables[0].Columns["DEPTNO"].ColumnName.ToString(); DropDownList1.DataBind(); [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft C# .NET
Binding two data columns to one DropDownList
Top