Changing a table properties in ASP.NET

Discussion in 'ASP .Net' started by Chris, Dec 31, 2003.

  1. Chris

    Chris Guest

    This should have been easy but I can't find the answer...

    I want to make every other row in my table a different row. I can't seem to
    find a way to do this through my Page_Load event like I thought I would
    because I can't grab the table object. The table has an ID so I don't see
    why I can't reference it in my event. Can anyone shed some light on how to
    go about this. Oh, I'm new to ASP.NET but do VB.NET often, so I may be
    missing some simple ASP concept...

    Thank
    Chris
     
    Chris, Dec 31, 2003
    #1
    1. Advertisements

  2. Chris

    Curt_C [MVP] Guest

    is it a <table...>
    or <asp:Table...>
    ?
     
    Curt_C [MVP], Dec 31, 2003
    #2
    1. Advertisements

  3. Chris

    Chris Guest

    It is an <table>

    I hope there is a way to do this without asp:table since the asp:table
    appears harder to format my controls on the screen correctly, but that just
    may be me unfamiliar with it. Can I do this change the table properties
    with a <table>?

    Thanks
     
    Chris, Dec 31, 2003
    #3
  4. Chris

    Curt_C [MVP] Guest

    somewhat....use the
    tablename.Attributes["style"] = "yourstyletags";
    Again though, it's only TABLE LEVEL items that will be available, not row,
    cell, etc...

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    www.Darkfalz.com
     
    Curt_C [MVP], Dec 31, 2003
    #4
  5. Chris

    Jos Guest

    Did you add the runat="server" attribute?
    After that, you can reference your table (it will take the type of
    HtmlTable). Use the Rows property to address the different
    rows.
     
    Jos, Dec 31, 2003
    #5
  6. Chris

    Chris Guest

    Thanks Joe, that is what I was missing, but now the new question is why I
    can't access a nested Table by name.

    I can see the second table my going down through the first one
    OuterTable.Rows(1).Cells(0).Controls(1).ID but I can't just reference the
    table named Inner when I put runat="server" on the table line. Any
    Thoughts?

    Chris
     
    Chris, Jan 2, 2004
    #6
  7. Chris

    Chris Guest

    Sorry, it does seem to be working... Don't know what I did wrong. Thanks a
    Ton.

    Chris
     
    Chris, Jan 2, 2004
    #7
  8. Chris

    Curt_C [MVP] Guest

    Make sure it's being defined in the code-behind. Often nested server
    controls will fail to auto-generate the necessary code-behind.
     
    Curt_C [MVP], Jan 2, 2004
    #8
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.