Solved

Gridview Header Image

Posted on 2012-03-30
5
544 Views
Last Modified: 2012-03-31
I'm trying to display a background image in my gridview header. This is what I have so far but it won't display the image. Any help is appreciated.


<asp:GridView ID="Users" runat="server" AutoGenerateColumns="False" CssClass="myheader"
                PageSize="20" AllowPaging="True" ondatabound="Users_DataBound" BackColor="Transparent"
                onpageindexchanging="Users_PageIndexChanging">                
                <Columns>
                    <asp:BoundField HeaderText="Emp_Id" DataField="Emp_Id" />
                    <asp:BoundField HeaderText="Last Name" DataField="Last_Name" 
                        ItemStyle-HorizontalAlign="Left" >
                    </asp:BoundField>
                    <asp:BoundField DataField="First_Name" HeaderText="First Name" 
                        ItemStyle-HorizontalAlign="Left" >
                    </asp:BoundField>
                </Columns>
                <HeaderStyle BorderStyle="None" />
            </asp:GridView>

Open in new window

0
Comment
Question by:baxtalo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 37789530
0
 
LVL 36

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
ID: 37789540
Please disregard my first comment,
For header only, you need to use css.
Check:
http://bytes.com/topic/asp-net/answers/513572-background-image-gridview-header
0
 

Author Comment

by:baxtalo
ID: 37789609
I tried it with no success. Maybe I'm missing something. This is what I put in my css file:
..gvHeaderRow
{
background-image:url(../images/background_silver.jpg)
}
After that I added CssClass here:

<asp:GridView ID="Users" runat="server" AutoGenerateColumns="False"
PageSize="20" AllowPaging="True" ondatabound="Users_DataBound"
onpageindexchanging="Users_PageIndexChanging" CssClass="gvHeaderRow">
0
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 250 total points
ID: 37789793
You have set CssClass for the whole gridview and not for header portion. So code as:

stylesheet code part: (ensure the url part in .css file in context to root and class name should be prefixed with single dot)
.gvHeaderRow
{
    background: url('Images/background_silver.jpg') repeat-x;
    color: #01354d;
    height: 25px;
    color: White;
}

Open in new window


.aspx code part (set headerstyle css class)
<asp:GridView ID="Users" runat="server" AutoGenerateColumns="False" CssClass="myheader"
                PageSize="20" AllowPaging="True" ondatabound="Users_DataBound" BackColor="Transparent"
                onpageindexchanging="Users_PageIndexChanging">                
                <Columns>
                    <asp:BoundField HeaderText="Emp_Id" DataField="Emp_Id" />
                    <asp:BoundField HeaderText="Last Name" DataField="Last_Name" 
                        ItemStyle-HorizontalAlign="Left" >
                    </asp:BoundField>
                    <asp:BoundField DataField="First_Name" HeaderText="First Name" 
                        ItemStyle-HorizontalAlign="Left" >
                    </asp:BoundField>
                </Columns>
                <HeaderStyle CssClass="gvHeaderRow" />
            </asp:GridView>

Open in new window

0
 

Author Closing Comment

by:baxtalo
ID: 37790982
Thank you very much; I've learned something from both of you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question