Adding a listitem to a table cell

H

Hong Yip

Hi Everyone,

I have an array of checkboxlist. Everything works prefectly fine until I
start working on the "presentation" view. I am not able to "insert" a
checkbox item to a table cell.

Something like that,

TableCell TCell = new TableCell();

TCell.Control.Add( .....);

Is there a way to add the list item into a table cell?

Thanks!


Regards,
Hong Yip
 
B

Brock Allen

I might be missing your question, but you can do this:

TableCell cell = new TableCell();
CheckBox cb = new CheckBox();
cell.Controls.Add(cb);
MyTable.Rows[SomeRow].Cells.Add(cell);

Since you're dynamically creating the control, you'll have to recreate it
upon every postback if you want it to retain its state.
 
S

Steven Cheng[MSFT]

Thanks for Brock's suggestions.

Hi Hong,

As Brock has mentioned, we can dynamically create individual web controls
and add them in a TableCell. Also, I'm not sure whether what you want is to
add a ListItem into a TableCell? If so, I'm afraid this is not allowed
since ListItem are not a WebControl ,they must be added into an existing
ListControl. For example, we should generate a DropDownList or ListBox
control and programmly add listItem (or through databinding) to fill them ,
then add the DropDownList or ListBox into Table Cell.

Please feel free to post here if there're any further questions. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
H

Hong Yip

Hi Brook & Steven Cheng

Thanks for the reply.

Yes, Brook, What I really want to do is to add a listitem into a TableCell.
Reason why I am putting into a TableCell is to 'tidy up' the presentation
view of my array of checkboxlist. I guess I have to look at my data
structure architecture to see if I can change it the way Brook has suggested
it.


Regards,
Hong Yip
 
S

Steven Cheng[MSFT]

OK. If there're any further questions or anything else we can help, please
feel free to post here.

Good Luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top