Wednesday, April 6, 2011

ASP.NET: GRIDVIEW: How to strikeout the entire text in a row

Hi, I need to strikeout the entire text(even the whitespace between text/cells) in a row in the RowDataBound event of the GridView. Is it possible?

From stackoverflow
  • Yes, you can put all your rows cell's content into <strike> tag. Example,

    row.Cell[0].Text = "<strike>cell content from row.DataItem</strike>";
    

    But it will only strike text in the cells. If you have cellpadding and cellspacing set to the row's table, then it might now look nice.

    renegadeMind : This just strikes out the text in the cell, i want to strikeout the entire row, even the whitespace between text/cells.
    Sachin Gaur : Those whitespace are there because of cellspacing, cellpadding, or margin applied to table. Send your HTML snippet of GridView, if possible.
  • C#

    on RowDataBound event

    e.Row.Style.Value = "text-decoration:line-through;"
    

    this is how your GridView will be rendered, it works !

    <table>
    <tr style="text-decoration:line-through;">
    <td>some text</td>
    <td>some text</td>
    </tr>
    <tr style="text-decoration:line-through;">
    <td>some text</td>
    <td>some text</td>
    </tr>
    <tr style="text-decoration:line-through;">
    <td>some text</td>
    <td>some text</td>
    </tr>
    </table>
    
    renegadeMind : didn't work for me, maybe some other style is overriding it, am not sure.
    roman m : you can use firebug to see if styles get overridden, but since this style is inline, it should have the priority
    renegadeMind : i can see the style being applied for the row using developer toolbar, but it just doesn't seen to work!!
    renegadeMind : Thanks for the effort, but this still wont strikeout the entire text(even the white space between text/cells) in the row.
    renegadeMind : I've also tried this - e.Row.Font.Strikeout = true; but even this doesn't work!
    roman m : the only way to "strike out the white space between the cells" is to have TEXT (in form of  ) in it. you can also try applying a background image to the row with a line through the middle to mimic the empty space strikeout.
  • can any one help me out with the answer

0 comments:

Post a Comment