I'm back on csla afther a year , still need some starters advice.

I'm back on csla afther a year , still need some starters advice.

Old forum URL: forums.lhotka.net/forums/t/2716.aspx


redgoblin83 posted on Tuesday, April 17, 2007

So, here is my first question for 2007:

 

I have a table with all kind of types sorted with a group id and an index, like:

1 20 Status 1 Open
2 20 Status 2 Closed
3 30 Strengt 1   Strong
4 30 Stringt 2 Weak

and so on

Whats the best way to have only the group items 20 in a combo box using csla objects. I thougt using the NameValueList, And have a stored procedure that has a group parameter. I tried with the codesmith templates and the NameValueList template but I got errors with the RootCommand.

So if i'm right afther some test it seems that an NameValueList object is made to operate with a table that has two items. So I could split up my table or ...

And thats where you folks can help me out. I re orded the book, had to leave the one I bought for shool.

Kind Regards,

RockfordLhotka replied on Saturday, April 28, 2007

NameValueListBase is designed specifically to support things like a combobox, where you need a key value and a display value, so it is probably appropriate here.

There are some 3rd party combobox controls that can display multiple values in the dropdown (as columns) and then you need to use a ReadOnlyListBsae collection of ReadOnlyBase objects that expose the properties to be displayed.

david.wendelken replied on Monday, April 30, 2007

If you make one NameValueList class per group, you would have a public factory method like this for group 20:

public static MyGroup20NVList GetList()

and another method in the group 30 class:

public static MyGroup30NVList GetList()

If you wanted to make one NameValueList class that would work for any group, you would have a a factory method like this:

public static MyGroupNVList GetList(int groupId).

In the first two cases, the method would pass in a hidden, fixed group id to your database procedure (20 and 30, respectively).  In the third case, it would pass back the value in the groupId parameter.

As for NameValueList only working for two column tables, that isn't so.  Creative use of concatenation can allow you to show multiple column values in the "Name" portion of the NameValueList.  Consider right-padding the fields to their maximum length if that would improve readability.

 

 

Copyright (c) Marimer LLC