Adding Title/Caption to Gridview
While trying to answer one of the post about GridView.Caption property, I realized that you can assign a full HTML rather than a simple text. This means that you can be creative in designing what your caption looks like. Following simple example illustrates using some HTML tags to define the border and background color to the caption area:
<asp:GridView ID="GridView1" runat="server" ...
Caption='<table border="1" width="100%" cellpadding="0" cellspacing="0" bgcolor="yellow"><tr><td>Grid Heading</td></tr></table>' CaptionAlign="Top">
What this does is to insert a Table that fills the Caption region (width="100%" ensures same width as that of the GridView) while using Yellow background color. What's more, it opens the door to adding captions that are limited only by your imagination.
Refer:
http://forums.asp.net/t/966407.aspx/1?How+can+I+add+Caption+Title+to+GridView+
The width doesn't work for some reason on mine. It is displaying as a little box to the left of the gridview. Is there something I'm missing?
ReplyDelete