473,405 Members | 2,141 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,405 software developers and data experts.

dataset and dropdownlist

I have an assembly that contains a function that returns a dataset. I want to
bind that dataset to a dropdownlist. If I do it as such:

DataSet ds;
ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0].DefaultView;
droplist.DataTextField =
Convert.ToString(ds.Tables[0].Columns["column"].ColumnName);

The droplist displays System.Data.DataRowView and I have had a brainfart and
can't seem to fix this simple problem. Suggestions Please!

Thanks
Marty U.
Nov 18 '05 #1
4 18879
I think the DataTextField property is not properly set. Just specify the
column name directly to the DataTextField instead of fetching it from the
ColumnName proeprty and then converting it to a string...

"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
I have an assembly that contains a function that returns a dataset. I want
to
bind that dataset to a dropdownlist. If I do it as such:

DataSet ds;
ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0].DefaultView;
droplist.DataTextField =
Convert.ToString(ds.Tables[0].Columns["column"].ColumnName);

The droplist displays System.Data.DataRowView and I have had a brainfart and
can't seem to fix this simple problem. Suggestions Please!

Thanks
Marty U.
Nov 18 '05 #2
try this
DataSet ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0]; // or droplist.DataSource = ds; if you
only have one table within the dataset
droplist.DataTextField = ds.Tables[0].Columns["TextValueColumn"].ToString();
// or you can use droplist.DataTextField = "TextValueColumn";
droplist.DataValueField =
ds.Tables[0].Columns["DataValueColumn"].ToString(); // or you can use
droplist.DataTextField = "DataValueColumn";
droplist.BindData();
ds.Dispose(); // if you dont need the object

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
I have an assembly that contains a function that returns a dataset. I want to bind that dataset to a dropdownlist. If I do it as such:

DataSet ds;
ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0].DefaultView;
droplist.DataTextField =
Convert.ToString(ds.Tables[0].Columns["column"].ColumnName);

The droplist displays System.Data.DataRowView and I have had a brainfart and can't seem to fix this simple problem. Suggestions Please!

Thanks
Marty U.

Nov 18 '05 #3
Yep now I know why I don't normally work on Saturdays, on top of the other
items I was even referencing a column from the wrong da*n table.

Thanks folks.

"Hermit Dave" wrote:
try this
DataSet ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0]; // or droplist.DataSource = ds; if you
only have one table within the dataset
droplist.DataTextField = ds.Tables[0].Columns["TextValueColumn"].ToString();
// or you can use droplist.DataTextField = "TextValueColumn";
droplist.DataValueField =
ds.Tables[0].Columns["DataValueColumn"].ToString(); // or you can use
droplist.DataTextField = "DataValueColumn";
droplist.BindData();
ds.Dispose(); // if you dont need the object

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
I have an assembly that contains a function that returns a dataset. I want

to
bind that dataset to a dropdownlist. If I do it as such:

DataSet ds;
ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0].DefaultView;
droplist.DataTextField =
Convert.ToString(ds.Tables[0].Columns["column"].ColumnName);

The droplist displays System.Data.DataRowView and I have had a brainfart

and
can't seem to fix this simple problem. Suggestions Please!

Thanks
Marty U.


Nov 18 '05 #4
glad you got it sorted and that we could help.. have a nice one

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Yep now I know why I don't normally work on Saturdays, on top of the other
items I was even referencing a column from the wrong da*n table.

Thanks folks.

"Hermit Dave" wrote:
try this
DataSet ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0]; // or droplist.DataSource = ds; if you only have one table within the dataset
droplist.DataTextField = ds.Tables[0].Columns["TextValueColumn"].ToString(); // or you can use droplist.DataTextField = "TextValueColumn";
droplist.DataValueField =
ds.Tables[0].Columns["DataValueColumn"].ToString(); // or you can use
droplist.DataTextField = "DataValueColumn";
droplist.BindData();
ds.Dispose(); // if you dont need the object

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
I have an assembly that contains a function that returns a dataset. I
want to
bind that dataset to a dropdownlist. If I do it as such:

DataSet ds;
ds = myobject.GetDataSet();
droplist.DataSource = ds.Tables[0].DefaultView;
droplist.DataTextField =
Convert.ToString(ds.Tables[0].Columns["column"].ColumnName);

The droplist displays System.Data.DataRowView and I have had a
brainfart and
can't seem to fix this simple problem. Suggestions Please!

Thanks
Marty U.


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: TonyM | last post by:
Hi All, Please bear with me on this, I'm not 100% sure I know how to ask this clearly. I have a Web Application that I'm trying to keep the items you can select in a DropDownList in a...
3
by: Bill | last post by:
I have a seating chart web form that has over 50 entry field controls (tables/booths) where I use a DropDownList box to select a single company name from a single large list of organizations (200...
0
by: TK | last post by:
Hi, I need help on datagrid. I have a dataset exposed as a webservice. I do have a web application that is supposed to consume the service on a datagrid.
4
by: Iain Kirk | last post by:
Being a bit of a novice any help or pointers would be appreciated. I am building a web page that populates a DropDowList from a table in SQL, for testing purposes i have a simple page that...
15
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
2
by: jdsharp | last post by:
I understand how to bind the Dropdownlist control to a table so that it shows the list of values, but how do I bind it to my main data entry dataset? Thanks for the help! Jason
12
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource =...
4
by: somersbar | last post by:
hi, i need to create a new dataset at runtime in a button event handler. can anyone start me off in the right direction?
11
by: ^MisterJingo^ | last post by:
Hi all, I have a form with 4 dropdownlist controls which I populate with data from DB tables. I have a class with a method which constructs a dataset, putting each DB table into a dataset table....
1
by: Probi | last post by:
HI, I have a DropDownList populated from database I use the following code OracleDataAdapter ad2 = new OracleDataAdapter(cmd2, connection); DataSet ds2 = new DataSet(); ad2.Fill(ds2); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.