Wednesday, 17 April 2013

GridView; Alter the Style of GridView Row, Column

Requirment:
  1. You have to change the Column into TemplateField
How to alter the style of the Row and Column:
  1. At first make the header row in Multi line as well One simplest example:
  2. <HeaderTemplate>Line1<br />Line2</HeaderTemplate>
  3. Then in order the change the column field width set it inside <ItemTemplate> tag
HTML:

        <asp:TemplateField HeaderText="AdmissionNumber"
            SortExpression="AdmissionNumber">
            <HeaderTemplate>Admission <br /> Number</HeaderTemplate>
            <EditItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("AdmissionNumber") %>' 
                   ></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("AdmissionNumber") %>'
                    Width="30px" Height="19px" BackColor="#FFCCFF"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>


No comments:

Post a Comment