472,107 Members | 1,238 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,107 software developers and data experts.

How to bind to the text element of a checkboxlist web control?

Hello all,

I have googled like crazy for this with no sucess!

I have a dataset containing a table with the following fields

WidthID---int (primary key)

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()+")";
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

May 20 '07 #1
0 1247

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Egbert | last post: by
4 posts views Thread by dm_dal | last post: by
2 posts views Thread by John Hoge | last post: by
7 posts views Thread by bienwell | last post: by
reply views Thread by =?Utf-8?B?RG90TmV0RGV2?= | last post: by
reply views Thread by leo001 | last post: by

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.