views:

189

answers:

1

Is it possible to set the a gridview's headerrow property from the aspx code? I'd like to be able to include extra controls to the header such as textbox for filter. I can do this from the C# code behind by dynamically adding the controls, but doing this seems to introduce some suitable problems that I'd rather avoid.

+2  A: 

Use a header template field.

<columns>
    <asp:templatefield>
        <headerstyle backcolor="Navy" forecolor="White"/>
        <headertemplate>
            <asp:textbox id="txtFilter" runat="server"/>
        </headertemplate>
    </asp:templatefield>                      
</columns>

See here.

Phaedrus
Thanks! Completely missed that.
Robert