By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Adding a listitem to a table cell

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #2

P: n/a
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.)

Nov 19 '05 #3

P: n/a
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

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Xt**************@TK2MSFTNGXA01.phx.gbl...
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.)

Nov 19 '05 #4

P: n/a
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.)

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.