Extend TableCell

Discussion in 'ASP .Net' started by Matthi, Apr 4, 2006.

  1. Matthi

    Matthi Guest

    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
    Matthi, Apr 4, 2006
    #1
    1. Advertising

  2. 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.

    "Matthi" <> wrote in message
    news:...
    >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
    >
    Kevin Spencer, Apr 4, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. x

    capture a tablecell event

    Mr. x, Sep 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,125
    Mr. x
    Sep 2, 2003
  2. Serdar Kalaycý

    TableCell

    Serdar Kalaycý, Jun 30, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    587
    Karl Seguin
    Jun 30, 2003
  3. May
    Replies:
    0
    Views:
    376
  4. Jurjen de Groot

    Inserting text into TableCell at runtime

    Jurjen de Groot, Aug 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    488
    Xavier MT
    Aug 18, 2003
  5. Brian K. Williams

    TableCell oTableCell = new TableCell(); noWrap?

    Brian K. Williams, Apr 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,513
    Brian K. Williams
    Apr 30, 2004
Loading...

Share This Page