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

Need help creating list of business objects

I'm new to c# and .net 2.0. In the old vb.net 1.1 days I normally created a
list class for every business class and used this list class for all
databinding rather than using datasets. This is because often I wanted to
edit data in the list and therefore needed to talk to the business object
and not the dataset. Since this was a must, I standardized on creating list
objects in most cases so everything was standardized. I've searched far and
wide and have found little documentation on the latest and greatest way to
create bindable custom list classes. What is the best practice these day in
creating bindable list classes? Where's good documentation about this?

Thanks.

--
mo*******@nospam.nospam
Mar 5 '06 #1
10 5079
Hi moondaddy
Here you can find a usefull summary of creating list of business
objects for binding using BindlingList class of .Net Framework 2.0 ( a
cool feature !) :

http://blogs.msdn.com/dchandnani/arc...12/394438.aspx

you can search the web for BindingList class, too.
I hope this helps

A.Hadi

Mar 5 '06 #2
Thanks. That was a useful link. However, when I try it, I'm getting an
error in every cell of the gridview and haven't identified why yet. Also, I
usually have added functionality in my list classes. Is there a code
example of inheriting the BindingList class and creating a new list class
with it? I tried it but the controls and/or the designer could not see the
fields in the objects in the list.

Thanks again.

--
mo*******@nospam.nospam
"Aboulfazl Hadi" <AH****@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hi moondaddy
Here you can find a usefull summary of creating list of business
objects for binding using BindlingList class of .Net Framework 2.0 ( a
cool feature !) :

http://blogs.msdn.com/dchandnani/arc...12/394438.aspx

you can search the web for BindingList class, too.
I hope this helps

A.Hadi

Mar 6 '06 #3
Hi
post your sample code, please

A.Hadi

Mar 6 '06 #4
Hi moondaddy,

Thanks for your feedback.

Yes, I have downloaded your sample project and reproduced out this
behavior.

Actually, the cell error is displayed by IDataErrorInfo interface. When
DataGridView shows the cells, it will query IDataErrorInfo interface and
display the error message. If you return an empty error message for
IDataErrorInfo.Error and IDataErrorInfo.this[] property, the cell error
icon will disappear. Like below:

#region IDataErrorInfo Members

public string Error
{
get { return ""; }
//return "some error stub";
}

public string this[string columnName]
{
get { return ""; }
}

#endregion
Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mar 7 '06 #5
Thanks Jeffrey! Question. If I return an empty string, then what logic do
I use to know when to return an error. Is this based on my business logic
where I would set a private variable to some error message that this would
pick up (there must be a better way to pass a error msg to this event)? How
would I know when to pass an error msg for one specific cell and not all of
them?

--
mo*******@nospam.nospam
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.com> wrote in message
news:Gr**************@TK2MSFTNGXA03.phx.gbl...
Hi moondaddy,

Thanks for your feedback.

Yes, I have downloaded your sample project and reproduced out this
behavior.

Actually, the cell error is displayed by IDataErrorInfo interface. When
DataGridView shows the cells, it will query IDataErrorInfo interface and
display the error message. If you return an empty error message for
IDataErrorInfo.Error and IDataErrorInfo.this[] property, the cell error
icon will disappear. Like below:

#region IDataErrorInfo Members

public string Error
{
get { return ""; }
//return "some error stub";
}

public string this[string columnName]
{
get { return ""; }
}

#endregion
Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mar 7 '06 #6
It would be cool if you could do:

public class Customer
{
public string Name;
public ComboBox ShoeSize;
public ProgressBar DownloadProgress;
}

And do a binding list to grid or listview and have it display the combo box
and progress bar in the column automatically.
--
William Stacey [MVP]

"Aboulfazl Hadi" <AH****@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
| Hi moondaddy
| Here you can find a usefull summary of creating list of business
| objects for binding using BindlingList class of .Net Framework 2.0 ( a
| cool feature !) :
|
| http://blogs.msdn.com/dchandnani/arc...12/394438.aspx
|
| you can search the web for BindingList class, too.
| I hope this helps
|
| A.Hadi
|
Mar 7 '06 #7
This would be cool. anyone out there have any good ideas on this?

--
mo*******@nospam.nospam
"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
It would be cool if you could do:

public class Customer
{
public string Name;
public ComboBox ShoeSize;
public ProgressBar DownloadProgress;
}

And do a binding list to grid or listview and have it display the combo
box
and progress bar in the column automatically.
--
William Stacey [MVP]

"Aboulfazl Hadi" <AH****@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
| Hi moondaddy
| Here you can find a usefull summary of creating list of business
| objects for binding using BindlingList class of .Net Framework 2.0 ( a
| cool feature !) :
|
| http://blogs.msdn.com/dchandnani/arc...12/394438.aspx
|
| you can search the web for BindingList class, too.
| I hope this helps
|
| A.Hadi
|

Mar 7 '06 #8
Hi moondaddy,

Thanks for your feedback.

We can create a SetObjectError() method in Person_BLL class, which sets
"Error" and "this[string columnName]" property error string. Then for
Person_BLL class usage developer, he can use SetObjectError() to set the
error information.

In FCL, DataRowView class implements IDataErrorInfo interface, and DataRow
exposes SetColumnError method to set the error.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mar 7 '06 #9
Thanks. I see plenty of documentation about SetColumnError in regards to
datasets and datarows, however, I doesn't really help me get my arms around
how to use a SetObjectError method in a business object. Can you recommend
some documentation or code examples? I found an example by Rocky Lhotka
Feb. 2003 which used old vb code. That example shows a red error 'dot' for
each grid row and not each cell. This way he could check the validity of
all properties in the Error property and return a string showing all errors.
What I don't understand is how to return a specific error for a specific
cell.

--
mo*******@nospam.nospam
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.com> wrote in message
news:d%***************@TK2MSFTNGXA03.phx.gbl...
Hi moondaddy,

Thanks for your feedback.

We can create a SetObjectError() method in Person_BLL class, which sets
"Error" and "this[string columnName]" property error string. Then for
Person_BLL class usage developer, he can use SetObjectError() to set the
error information.

In FCL, DataRowView class implements IDataErrorInfo interface, and DataRow
exposes SetColumnError method to set the error.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mar 7 '06 #10
Hi moondaddy,

Sorry for the late response, I am OOF these days.

I can not find any definite sample regarding IDataErrorInfo. Maybe you can
search IDataErrorInfo in google for more information.

Actually, I did not see much difficulty in implementing this interface. As
I original said, IDataErrorInfo.Item property returns the specific cell
error message. In your implementation, one instance of Person_BLL is
expressed as a row in DataGridView. So, every column in this object
instance corresponding to one cell in that row. In this object, you can use
an Hashtable to store the error variable, which one item in the Hashtable
stores one column's error message.(we can use the columnName as the key)

In Person_BLL.SetObjectError method, we can pass the columnName as the
parameter, which can be used in this method to identify the error message
in Hashtable.(Yes, with the key(columName), we can find the item without
any problem)

Initially, all the items will be empty strings, so there will be no error
in DataGridView. Once, an item is non-empty string, it will express as an
error in corresponding cell.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mar 13 '06 #11

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

Similar topics

7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
10
by: pcthug | last post by:
Hi All, I am creating multi-tier app in vb.net using visual studio .net. I create a invoice.vb class file with properties, events and methods. This also has a line item collection class...
2
by: mattie | last post by:
hi, i was just reading an article on interface-based programming and the example they used was pretty good to get the concept across. dim dog as IDog dog=new CBeagle dog.bark ok, i kinda...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
0
by: Andrew | last post by:
I have created a Component called a BOConnector that implements IBindingList so it can provide access to a list of business objects to be bound to controls. At design time there is no live list...
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
1
by: BillG | last post by:
I am used to dealing with recordsets and I am using a coarse-grained object and need to know if I am doing it correctly. I have a class named Activity which represents an event being planned...
9
by: moondaddy | last post by:
using c# 3.5 I have list of business objects which I will use in lists for databinding and I want to hide some of the fields so they don't show up in the list control. some of my list will be:...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.