473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ListBox in asp.net,c#

Sir i am new in this fild,so plz help me
i want to retriv two column in ListBox from oracle table,i am able to retriv one column and my coding is this but i also want to retrive second column also.
my coding is
************************************************** ******************************************
strconn = new OleDbConnection();
strconn.ConnectionString= "Provider=msdaora.1;userid=payroll;password=payrol l; data source=payroll";
strconn.Open();
strsql = "select * from Employee where BillUnit=" + DdlBillUnit.SelectedItem.ToString() + " ";
OleDbCommand cmd1 = new OleDbCommand(strsql, strconn);
OleDbDataReader reader1 = cmd1.ExecuteReader();
LbUnselectedEmp1.DataValueField = "NAME";
LbUnselectedEmp1.DataSource = reader1;
LbUnselectedEmp1.DataBind();
reader1.Close();
strconn.Close();
************************************************** ******************************************
here i display NAME but i also want to display TITLE
please help
Jun 21 '07 #1
2 2217
Vidhura
99
Sir i am new in this fild,so plz help me
i want to retriv two column in ListBox from oracle table,i am able to retriv one column and my coding is this but i also want to retrive second column also.
my coding is
************************************************** ******************************************
strconn = new OleDbConnection();
strconn.ConnectionString= "Provider=msdaora.1;userid=payroll;password=payrol l; data source=payroll";
strconn.Open();
strsql = "select * from Employee where BillUnit=" + DdlBillUnit.SelectedItem.ToString() + " ";
OleDbCommand cmd1 = new OleDbCommand(strsql, strconn);
OleDbDataReader reader1 = cmd1.ExecuteReader();
LbUnselectedEmp1.DataValueField = "NAME";
LbUnselectedEmp1.DataSource = reader1;
LbUnselectedEmp1.DataBind();
reader1.Close();
strconn.Close();
************************************************** ******************************************
here i display NAME but i also want to display TITLE
please help

you can loop thru the values instead of binding with Listbox

sample:
for (int i = 0; i < table.Rows.Count - 1; i++)
{
string val=table.Rows[i]["ColName"].ToString() + "table.Rows[i]["ColString"].ToString();
ListBox1.Items.Add(new ListItem(val,table.Rows[i]["ColString"].ToString() ));
}
Jun 21 '07 #2
strconn = new OleDbConnection();
strconn.ConnectionString= "Provider=msdaora.1;userid=payroll;password=payrol l ; data source=payroll";
strconn.Open();
strsql = "select * from Employee where BillUnit=" + DdlBillUnit.SelectedItem.ToString() + " ";
OleDbCommand cmd1 = new OleDbCommand(strsql, strconn);
OleDbDataReader reader1 = cmd1.ExecuteReader();
while (reader1.Read())
{
Listbox1.Items.Add(reader1.GetString(0);
Listbox2.Items.Add(reader1.GetString(1);
}
reader1.Close();
strconn.Close();


Hope this servers you better


Sir i am new in this fild,so plz help me
i want to retriv two column in ListBox from oracle table,i am able to retriv one column and my coding is this but i also want to retrive second column also.
my coding is
************************************************** ******************************************
strconn = new OleDbConnection();
strconn.ConnectionString= "Provider=msdaora.1;userid=payroll;password=payrol l; data source=payroll";
strconn.Open();
strsql = "select * from Employee where BillUnit=" + DdlBillUnit.SelectedItem.ToString() + " ";
OleDbCommand cmd1 = new OleDbCommand(strsql, strconn);
OleDbDataReader reader1 = cmd1.ExecuteReader();
LbUnselectedEmp1.DataValueField = "NAME";
LbUnselectedEmp1.DataSource = reader1;
LbUnselectedEmp1.DataBind();
reader1.Close();
strconn.Close();
************************************************** ******************************************
here i display NAME but i also want to display TITLE
please help
Feb 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.