Hello all,
I have googled like crazy for this with no sucess!
I have a dataset containing a table with the following fields
Table===Widths
---------------------------------------------
WidthID---int (primary key)
Width------decimal
IsCustom---bool
MaxWidth--decimal
MinWidth---decimal
-----------------------------------------------
Basically it describes a collection of objects of either fixed size (Width)
or custom size given by the range MinWidth->MaxWidth.
All clear so far?
Now some other element in my database is linked (via a joining table) to a
collection of these avaliable widths.
I want a user to be able to search my database for all elements that have a
certain width (custom or fixed).
I have created a CheckBoxList that is populated with all avaliable widths.
The user simply checks the ones they want.
Now for the question.
I can bind the Primary key (WidthID) to my CheckBoxList control using its
DataValueField property.
I want to bind a custom built string to the text element of the
CheckBoxList....but there isn't one!
There is only a DataTextField property and that specifies the column in the
DataSource that it binds to.
Normally I would use something like...
Text="<%# GetWidths(Container.DataItem) %>
where GetWidths would be something like this...
protected string GetWidths(object o)
{
DataRowView DRW=(DataRowView) o;
if( (bool)DRW[2] )
{
return "Custom("+( (decimal)DRW[3] ).ToString()+"-"+(
(decimal)DRW[4] ).ToString()+")";
}
else
{
return ( (decimal)DRW[1] ).ToString();
}
}
But as there is no text field to bind to I am at a loss.
Am I missing something simple here?
Or will I have to create my own Repeater control with a checkbox and a
label?
Thanks
Sean.