Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET .NET4
I have created one grid view.following is the code
<asp:GridView ID="GridView1" runat="server" EnableModelValidation="True"
                ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" CssClass="mGrid1"
                  >
                <AlternatingRowStyle BackColor="Silver" ForeColor="#284775" />
                <Columns>
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:CheckBox ID="Mycheck" runat="server" />
                        </ItemTemplate>
                        <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                            CssClass="bg" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ContactID" Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="LblContactID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ContactID")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                            <asp:Label ID="LblContactName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FirstName")%>'></asp:Label>
                            <asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LastName")%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                            CssClass="bg" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="CompanyID" Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="LblCompanyID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CompanyID")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Company">
                        <ItemTemplate>
                            <asp:Label ID="LblCompany" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CompanyName")%>'></asp:Label>
                        </ItemTemplate>
                         <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                            CssClass="bg" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Mobile No.">
                        <ItemTemplate>
                            <asp:Label ID="LblMobileNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "MobileNumber")%>'></asp:Label>
                        </ItemTemplate>
                         <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                            CssClass="bg" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="BusinessID" Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="LblBusinessID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "BusinessID")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="TypeOfBusiness" Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="LblTypeOfBusiness" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TypeOfBusiness")%>'></asp:Label>
                        </ItemTemplate>
                         <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                            CssClass="bg" />
                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="Country">
                            <ItemTemplate>
                                <asp:Label ID="LblCountry" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Country")%>'></asp:Label>
                            </ItemTemplate>
                             <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" />
                            <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                                BackColor="#74ABD4" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="State">
                            <ItemTemplate>
                                <asp:Label ID="LblState" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "State")%>'></asp:Label>
                            </ItemTemplate>
                             <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" />
                            <HeaderStyle BorderColor="White" BorderStyle="Solid" BorderWidth="2px" 
                                BackColor="#74ABD4" />
                        </asp:TemplateField>
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                     <HeaderStyle BackColor="#74ABD4" Font-Bold="false" Width="100" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Height="30px" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            </asp:GridView>
and took one stlesheet grid.css
 
.mGrid1
{
   
    font-family: tahoma;
    
    
}
 
.mGrid1 td   /* this applies to the Gridviews Data fileds */
{
    padding: 1px;
    text-align:center;
    width: 3%;
   
    border-collapse: collapse;
}
.mGrid1 th   /* this applies to the Gridviews Headers */
{
     padding: 0px 0px;
     border-width: 1px;
}
.bg
{
    background: #74ABD4;
}
 
now what i want first column first row header "select" should have less width as compared to other .i am unable to achieve this pls tell......
regards
Posted 11-Jan-13 0:36am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i am getting my outlay correct ...what i was missing that i had a css class in master page which was overlapped by current tags
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,740
1 DamithSL 5,769
2 Sergey Alexandrovich Kryukov 5,424
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100