Databinding and empty rows

  • Thread starter Thread starter Anders K. Jacobsen [DK]
  • Start date Start date
A

Anders K. Jacobsen [DK]

Im developing an ASP.NET application. So far im pretty pleased. Databinding
is really nice but also gives me som e problems / design issues.

Lets say I want to bind a list of contries to a DropDownList in a search
form. Now I have a problem because I also want to let the user be able to
select "none" as an empty field. Now im manually adding a row to the
collection before bind but i dont fing that very pretty.

I could add a "No country selected" entry in my database and this would work
here but in other cases not.

What is the common way to do this?

It´s not that big a problem. I just want to hear your experts opinion in
this.

Regards
Anders
 
One common approach is to databind and then insert a place holder

drdown.databind();
drdown.insert(0,"Select an Item");

roughly

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
 
Anders,

Either way. What Alvin suggests or the other 2 ways you mentioned. Usually
it doesn't make any big difference. There are some cases though when it
does. For example, if you bind more than one ddl to the same collection, you
should add an empty item to the collection or to the table but not to every
ddl.

Eliyahu

Alvin Bruney said:
One common approach is to databind and then insert a place holder

drdown.databind();
drdown.insert(0,"Select an Item");

roughly

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
Anders K. Jacobsen said:
Im developing an ASP.NET application. So far im pretty pleased.
Databinding is really nice but also gives me som e problems / design
issues.

Lets say I want to bind a list of contries to a DropDownList in a search
form. Now I have a problem because I also want to let the user be able to
select "none" as an empty field. Now im manually adding a row to the
collection before bind but i dont fing that very pretty.

I could add a "No country selected" entry in my database and this would
work here but in other cases not.

What is the common way to do this?

It´s not that big a problem. I just want to hear your experts opinion in
this.

Regards
Anders
 
Back
Top