3
  <FooterTemplate>
    <tr style="background-color:Orange;">
    < td width="6%" align="center" id = "tdFooter" runat = "server" colspan = "3">                                   
    </td>
</tr>
</FooterTemplate>

I have a repeater control in which i have this footer template. All i want is to change the colspan of tdFooter at itemdatabound event(c#) on the basis of some if clauses.How can i do the same?

if (e.Item.ItemType == ListItemType.Footer)
{
    if(role = 0)
       {
         //tdfooter colspan should be 3
       }
else
      {
        //tdfoote colspan should be 2
      }
}
rohit singh
  • 550
  • 1
  • 11
  • 32

1 Answers1

6

I would add a runat to the td tag

<td runat="server" id="tdControl">

in the itemdatabound:

 var td = (HtmlTableCell)e.Item.FindControl("tdControl");
 td.Attributes.Add("colspan", myNumber);
rohit singh
  • 550
  • 1
  • 11
  • 32
Martin Davies
  • 4,436
  • 3
  • 19
  • 40
  • Also, I just found more or less the same thing answered here http://stackoverflow.com/questions/13241698/htmlgenericcontroltd-colspan – Martin Davies Apr 06 '13 at 10:59
  • 1
    hi thanks for the answer but instead of (HtmlGenericControl) it should be (HtmlTableCell) and now its working :) – rohit singh Apr 06 '13 at 11:04