tags:

views:

23

answers:

2

Can i in GridView add css to only first(headr) tr. I know how to add css to th inside header trr but i don't know if is possible to add css to trr?

GRIDVIEW:

<asp:GridView ID="gwCompanies" runat="server" AutoGenerateColumns="false">
        <Columns>            
            <asp:TemplateField HeaderText="Ime">               
                <ItemTemplate>
                    <asp:Image ID="imgServiceOpen" runat="server" ToolTip="Restavracija sprejema naročila" ImageUrl="~/Images/cheff-icon.png" Visible='<%# Convert.ToBoolean(Eval("ServiceOpen")) %>' />
                    <asp:HyperLink ID="hlEdit" runat="server" NavigateUrl='<%# GetOrderArticlesUrl(Eval("CompanyId")) %>'>
                        <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                    </asp:HyperLink>
                </ItemTemplate>                
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Naslov">
                <ItemTemplate>
                    <asp:Label ID="lblFullAddress" runat="server" Text='<%# GetFullCompanyAddress(Container.DataItem) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            <asp:Label ID="lblEmptyCompaniesGrid" runat="server" Text="Ne najdem restavracij!"></asp:Label>
        </EmptyDataTemplate>
    </asp:GridView>

output i want

<table id="rest_list">

  <tr class="top_tab">
    <td class="top_tab_title">Ime</td>
    <td class="top_tab_title">Naslov</td>
  </tr>

  <tr>
    <td class="rest_name"><a href="#" title="Murka">Murka</a></td>
    <td>Točen naslov pizzerije</td>
  </tr>

  <tr>
    <td class="rest_name"><a href="#" title="Lastoria">Lastoria</a></td>
    <td>Točen naslov pizzerije</td>
  </tr>

  <tr>
    <td class="rest_name"><a href="#" title="Skok">Skok</a></td>
    <td>Točen naslov pizzerije</td>
  </tr>

  <tr>
    <td class="rest_name"><a href="#" title="Tara">Tara</a></td>
    <td>Točen naslov pizzerije</td>
  </tr>

</table>
+1  A: 

You can add a class with the HeaderStyle property, like this:

<asp:GridView ID="gwCompanies" runat="server" AutoGenerateColumns="false">
  <HeaderStyle CssClass="top_tab" />

Or in the GridView tag, like this:

<asp:GridView ID="gwCompanies" runat="server" HeaderStyle-CssClass="top_tab" AutoGenerateColumns="false">
Nick Craver
thx for so fast answer
senzacionale
+1  A: 

Not sure I understand correctly, but you should use a HeaderTemplate to define your header row, e.g:

<asp:TemplateField HeaderText="Ime">               
  <ItemTemplate>
    ...
  </ItemTemplate>
  <HeaderTemplate>
    put here the content for the header row of this column
  </HeaderTemplate>
</asp:TemplateField>

Then you can apply whatever style you want to your header.

M4N
thx for so fast answer
senzacionale