473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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

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.
May 20 '07 #1
0 1332

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Egbert | last post by:
I use a System.Web.UI.WebControls.CheckBoxList object to fill a list. I need to label groups of checkboxes in the list by Category (Determined dynamically from the database) at runtime. Is it...
4
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
1
by: Tom | last post by:
Hi There are a Checkboxlist with 20 checkboxitems and a string "1,3,5,7,9,11,13,15,17,20" which are those selectedindex of the checkboxlist. I used a foreach looping to record those selectedindex...
2
by: John Hoge | last post by:
I'm looking for that elusive .net time saving magic. I have an application that presents a list of items which the user can select from. A CheckBoxList works great for that, but I want to query...
7
by: bienwell | last post by:
Hi, I'm using the CheckBoxList control in ASP.NET for Web development. This checkboxlist is bound by the database. If we have more items for this checkbox list, it takes space on the page. I...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
3
by: mercea | last post by:
hi all, i have inserted a checkboxlist in my gridview using the <item template>. but i want the checkbox text to be genarated at runtime i.e via textboxes(user input). i have 5 textboxes and 5...
0
by: =?Utf-8?B?RG90TmV0RGV2?= | last post by:
Hi, I have a checkboxlist and want to wrap the text so that it doesn't appear below the check box on the next line. I feel that I might have to rewrite the solution because of this limit on...
0
by: AnaOlinto | last post by:
Hi, I'm new using AJAX and I'm developing a page where I need to populate a CheckBoxList based on what the user types (it's like an AutoSuggest). I don't know how to bind the checkboxlist from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.