C
cw bebop
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();
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();