I know, this is a very simple question but...
I want to bound an ObjectDataSource with
a DropDownList.
And I want to do it like that :
Residential
Condominium
Duplex
Triplex
Land
Commercial Lands...
These come from a class with properties and I just want to insert blank
space or better, tab character in it. I tried it but when it come to the
browser, all my spaces are trim.
Why ?
bruce barker - 27 Aug 2007 20:59 GMT
if you use a real select, then you can use optgroup
<select>
<optgroup label="Residential">
<option>Condominium</option>
<option>Duplex</option>
<option>Triplex</option>
</optgroup>
<optgroup label="Land">
<option>Commercial</option>
</optgroup>
</select>
-- bruce (sqlwork.com)
> I know, this is a very simple question but...
>
[quoted text clipped - 17 lines]
>
>
Alexey Smirnov - 27 Aug 2007 21:18 GMT
> I know, this is a very simple question but...
>
[quoted text clipped - 15 lines]
>
> Why ?
use a non-breaking space character
Ghistos - 27 Aug 2007 22:06 GMT
Tks Bruce
I find on the net
http://www.codeproject.com/aspnet/DropDownListOptionGroup.asp
A dotNet dropdownList with the OptionGroup and Item based on what you say to
me.
It works very well...
I tried the   in my class but this method not work or maybe it's me.
Tks again
Lit - 27 Aug 2007 23:40 GMT
Ghistos,
have you been able to incorporate all the bug fixes for that Control from
the link you provided?
If you know a download that has all the fixed I appreciate it if you can
share it with us.
using the control as is I am getting
Error 1 The name 'ddlItems' does not exist in the current context
DropDownListOptionGroup.aspx.cs
Thank you,
Lit
> Tks Bruce
>
[quoted text clipped - 10 lines]
>
> Tks again
Ghistos - 28 Aug 2007 16:48 GMT
I'm not sure to understand your problem.
I create a user control with the code. There's no bugs in the adapter. For
the code in the ascx.cs this is what I have done with comments from the
article...
Where CategorieBatimentList is a generic list of CategorieBatimentInfo.
I loop in my collection and then add the objects in my dropdownlist.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CategorieBatimentList catBats =
CategoriesBatiment.GetCategoriesBatiment();
foreach (CategorieBatimentInfo catbat in catBats)
{
ListItem currentItem = new
ListItem(catbat.DescriptionFrancais, catbat.CodeCategorie);
currentItem.Attributes["OptionGroup"] =
catbat.DescriptionGroupeFrancais;
ddlCatBatiment.Items.Add(currentItem);
}
}
}