Tuesday 7 August 2012

"Set width of columns in Gridview and also set width of Grid. "


<asp:GridView ID="GridView1" runat="server" CellPadding="4" AutoGenerateColumns="False"
            EnableModelValidation="True" ForeColor="#333333" GridLines="None" Width="1000px" >
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:TemplateField HeaderText="AddressLine1">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("AddressLine1") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("AddressLine1") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
               
                <asp:BoundField DataField="City" HeaderText="City" ItemStyle-Width="25%" >
                </asp:BoundField>

                <asp:BoundField DataField="PostalCode" HeaderText="PostalCode"
                    ItemStyle-Width="25%" >
                </asp:BoundField>

                <asp:BoundField DataField="rowguid" HeaderText="rowguid" ItemStyle-Width="10%" >
                </asp:BoundField>

            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        </asp:GridView>

No comments:

Post a Comment