Change table bgcolor programmatically

Discussion in 'ASP .Net' started by sam, Jul 8, 2004.

  1. sam

    sam Guest

    Hello Group,
    I have a table which consists of few web datagrids. Based
    on certain condition, I want to change the table bgcolor from the code
    behind. Any help would be great!!

    Thanks,
    Sam.
     
    sam, Jul 8, 2004
    #1
    1. Advertisements

  2. sam

    Jos Guest

    Add the runat="server" attribute to the table tag like this:
    <table id="myTable" runat="server">

    From code then:
    myTable.bgColor="Green"

    Even better would be to create a style sheet, and change
    the class for the table:

    myTable.Attributes("class") = "nameOfTheGreenStyle"
     
    Jos, Jul 8, 2004
    #2
    1. Advertisements

  3. sam

    Bobby Ryzhy Guest

    HTML side
    <asp:Table ID="_table" Runat="server" />

    CS side
    protected System.Web.UI.WebControls.Table _table;

    _table.BackColor = System.Drawing.Color.Turquoise;

    Bobby Ryzhy
    [email protected] name of domain below
    http://www.weekendtech.net
     
    Bobby Ryzhy, Jul 8, 2004
    #3
    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.