473,409 Members | 1,970 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,409 software developers and data experts.

vb.net 2.0 Comobox datasource to an business object

All I have a business object that I have bound to my combobox:
Dim myLeagueList As coachingAppObjects.ro_leagueRootList
myLeagueList =
coachingAppObjects.ro_leagueRootList.GetLeagueRoot List
Me.cboLeagues.DataSource = myLeagueList

This works great, however, I would like to add a default item as the
first one on the list (for example: Please Select).

Please Select
Choice 1
Choice 2
Choice 3
However, whenever I do the following

cboLeagues.items.add("Please Select")

I get the following message:

Items collection cannot be modified when the DataSource property
is set.

Any suggestions?

Aug 2 '07 #1
1 2131
Add "Please Select" before you databind the control. Then set
AppendDataboundItems to True. That should do the trick.
======================================
David McCarter [Microsoft VB.NET MVP]
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485
"JeffV" wrote:
All I have a business object that I have bound to my combobox:
Dim myLeagueList As coachingAppObjects.ro_leagueRootList
myLeagueList =
coachingAppObjects.ro_leagueRootList.GetLeagueRoot List
Me.cboLeagues.DataSource = myLeagueList

This works great, however, I would like to add a default item as the
first one on the list (for example: Please Select).

Please Select
Choice 1
Choice 2
Choice 3
However, whenever I do the following

cboLeagues.items.add("Please Select")

I get the following message:

Items collection cannot be modified when the DataSource property
is set.

Any suggestions?

Aug 2 '07 #2

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

Similar topics

1
by: Stijn Goris | last post by:
Hi all, I 'm trying to do some pretty simple stuff but can't get it to work. I want to get some data from a database (on sql server) and show a column from the table in a combobox. I can copy...
1
by: MuZZy | last post by:
Hi, I just wonder if anybody could give me a hint on this: I have a ComboBox component on the form and it has some very long sting items. When the combobox drops down, the list of items doesn't...
3
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create...
3
by: Mike Gaab | last post by:
I am trying to use some of the new controls in VS 2005 but am having some difficulty. My business logic layer returns Collections of my business objects. I am used to just assigning these...
2
by: Steve | last post by:
Hi- OK, I've got a DataGridView, I've created a BindingSource from one of my Business Entity object (based on generated classes from EntitySpaces) I've left the default column setup so that all...
4
by: Andy | last post by:
Hi, I made some changes to a business assembly I have. Now in the UI solution, I'm trying to add new object data sources. For some reason, the wizard isn't letting me select my business...
1
by: bsaira | last post by:
Hi, I have created a dataset which retrieves years from database. I want to associate dropdownlist control with a datasource that populates the years value from database. The problem is...
1
by: TonyJ | last post by:
Hello! I'm looking at VS2005 which is a bit different to VS2003. If I for example click on the meny line Data and there choose Show Data Source or Add New Data Source these does not exist in...
2
by: cmrchs | last post by:
Hello, I have a GridView and an objectDataSource <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AllowPaging="True" /> <asp:ObjectDataSource...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.