Help with Creating a custom Checkboxlist control

burak

Well-known member
Joined
Jun 17, 2003
Messages
127
Hello,

I am using a checkboxlist control. I am having trouble with arranging the
description of the checkboxes so that they line up left
centered and couple of spaces away from the checkboxes.

In the asp code, this is easy because the checkbox
and the description are on separate columns.

<td class="left">
<input name="task" type="checkbox" id="task">
</td>
<td class="left"> rsData("tasks")
</td>

So we get a checkbox and left centered description
that looks like this:

 Teach courses pertaining to the chemical and
physical properties and compositional changes of
substances.

( the above description is left aligned, but may not show like that on the forum,)
( "physical" and "substances" fall right under "Teach ")

In the .net code, the checkboxlist control is in one
column, hence both the checkbox and the description
show up in the same column.

<td>
<asp:checkboxlist id="Checkboxlist2"
DataValueField="company_name" TextAlign="right"
DataTextField="company_name"
DataTextFormatString="&nbsp;&nbsp;&nbsp;&nbsp; {0}"
Runat="server"></asp:checkboxlist>
</td>

and we end up with

 Teach courses pertaining to the chemical and
physical properties and compositional changes of
substances.

which does not look good.

I suspect the solution might have something to do with
RenderBeginTag and RenderEndTag methods, but I am not
sure.

Do you know how I can create a custom checkboxlist control so that the text will appear
like the asp version?

Thank you,

Burak
 
One option might be this, to fake ASP.NET out and close the
table data tag yourself to keep the checkbox in its own column.
Im not sure if or how well this will work, but try setting
DataTextFormatString to "</td><td>{0}".
 
Back
Top