Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:43:20+00:00 2026-06-04T02:43:20+00:00

How can i set the (css) style of a cell in an asp:DataGrid ?

  • 0

How can i set the (css) style of a cell in an asp:DataGrid?


What am i really trying to achieve? An html table, where i control the per-cell html content, and the per-row and per-cell css style:

<TABLE>
   <TR class="odd available">
      <TD class="holiday available hassub firstColumn">
          <P ...>...
      <TD class="blackout">
          <A href="...">...</A>
      <TD style="available">
          <SPAN ...>...</SPAN>
      <TD class="booked">
          <DIV ...>...</DIV>
      <TD class="orphan available">
          <DIV ...>...</DIV>
      <TD style="orphan booked checked">
          <SPAN ...>...</SPAN>
          <A href="...">...</A>
          <DIV ...>...</DIV>
   </TR>
   <TR class="blackout">
      <TD>34 points
      <TD><%# GetHtmlForCell() %>
   </TR>
</TABLE>

And it is accepted that an asp:Repeater cannot work in this case.

i have HTML that i need to generate; and i just have to see if ASP.net can generate required html. i’m guessing not, since “WebForms” means you don’t generate HTML.

Bonus Chatter

An asp:DataGrid control in ASP.net renders multiple cells. The formatting of each style can be adjusted by setting various formatting properties, for example:

  • BackColor
  • ForeColor
  • Font

But there is no way to adjust the Style of a cell, e.g.

style="holiday blackout hassub"

Bonus Reading

Some unrelated bonus reading:

  • Change the style of cell within datagrid
  • MSDN: DataGridViewCellStyle Class
  • How to set the style of a cell in an asp:ListView?
  • Create a HTML table with an ASP repeater
  • How to create a three column table in ASP.Net Repeater
  • custom html code in a repeater
  • MSDN: Cell Styles in the Windows Forms DataGridView Control
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:43:21+00:00Added an answer on June 4, 2026 at 2:43 am

    Assuming that you actually mean a GridView instead of the old DataGrid, you can use the CssClass property for the GridViewRow and TableCells.

    For example in RowDataBound:

    protected void Grid_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
            if(e.Row.RowIndex == 0)
            {
                e.Row.CssClass = "odd available";
                e.Row.Cells[0].CssClass = "holiday available hassub firstColumn";
                // ....
                e.Row.Cells[4].CssClass = "orphan booked checked";
            }
            else if(e.Row.RowIndex == 1)
                e.Row.CssClass = "blackout";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My asp.net theme has default css style. How can I set default style to
can you set the the image size of this control with css? <img style=border-width:
Hi im trying to set the css style for this but I dont know
I'm trying to learn how to put table content into css floats. My approach
In essence what I'm trying to do is create a CSS style that can
Can I set a different background-image CSS attribute to my <BODY> tag depending on
I'm new to shadow in css can we set shadows for round image(i mean
I have an image set by css style to 100x75. When it doesn't load,
how can i set the css (background)property from the server? Does not work at
Using CSS, i can set the corner radius of the top corners of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.