Extend TableCell

M

Matthi

I have an aspx page with a huge ASP Table in it. I need to add some
properties to its TableCells, but the table was cerated with the
designer, and not with custom code.
I can create a "MyTableCell" that extends from TableCell and add the
properties I want, but how can I change the ASP Table to use
MyTableCell instead of the default TableCell class for the cells?

Thanks
 
K

Kevin Spencer

Whether you use a Designer to create the table or not is not relevant, other
than the fact that in order to do what you want, you will have to go beyond
the Designer to do it.

You have a couple of alternatives, depending upon what you want to do with
it. First, since your TableCell class inherits TableCell, you can manually
add these to a Table, as in:

<asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="3">
<asp:TableRow>
<myPrefix:myTableCell Text="(0,0)"></myPrefix:myTableCell>
<myPrefix:myTableCell Text="(0,1)"></myPrefix:myTableCell>
<myPrefix:myTableCell Text="(0,2)"></myPrefix:myTableCell>
</asp:TableRow>
<asp:TableRow>
<myPrefix:myTableCell Text="(1,0)"></myPrefix:myTableCell>
<myPrefix:myTableCell Text="(1,1)"></myPrefix:myTableCell>
<myPrefix:myTableCell Text="(1,2)"></myPrefix:myTableCell>
</asp:TableRow>
</asp:table>

You will need to do some casting in your code to get at the new properties
in the cells. You may need to code the creation of the Table, depending upon
your requirements.

Second, you can create inherited Table and TableRow classes which work
directly with your new class.

Finally, you can go all the way and create a Designer for the whole thing if
you like.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top