- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have got some help with placing a background image on a gridview cell which works but now when I put text in the cell it is aligned to the top of the cell and not the middle. All other cells are aligned to the middle. The gif file is a green circle and I want the value to appear over it.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False
CellPadding="4" ForeColor="#333333" GridLines="None" CssClass="gridviewStyle">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="fld
DataNavigateUrlFormatStrin
HeaderText="KRI" />
<asp:TemplateField HeaderText="Date" SortExpression="fldDate">
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Bind("fldDate", "{0:dd/MM/yyyy}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("fldDate") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Month">
<ItemTemplate>
<div style="background-image:ur
<asp:Label ID="Label1" runat="server"
Text='<%# bind("fldstatusmonth") %>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="YTD">
<ItemTemplate>
<img src='<%# Eval ( "fldStatusYTD", "images/{0}.gif" ) %>'>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="fldComment"
HeaderText="Comment" SortExpression="fldComment
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
here is the resulting html code -
<table class="gridviewStyle" cellspacing="0" cellpadding="4" border="0" id="ctl00_ContentPlaceHold
<tr style="color:White;backgro
<th scope="col">KRI</th><th scope="col">Date</th><th scope="col">Month</th><th scope="col">YTD</th><th scope="col">Comment</th>
</tr><tr align="center" valign="middle">
<td><a href="/ews/hs/hsdisplay.as
<span id="ctl00_ContentPlaceHold
</td><td>
<div style="background-image:ur
<span id="ctl00_ContentPlaceHold
</div>
</td><td>
<img src='images/4.gif'>
</td><td> </td>
</tr>
</table>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: lijunguoPosted on 2008-08-28 at 16:29:27ID: 22340913
make changes to your DIV style. add : line-height:50px;
l('<%# Eval ( "fldStatusMonth", "/ews/images/{0}.gif" ) %>');background-repeat:no-r epeat;back ground-pos ition:cent er;height: 50px;verti cal-align: middle;">
l('<%# Eval ( "fldStatusMonth", "/ews/images/{0}.gif" ) %>');background-repeat:no-r epeat;back ground-pos ition:cent er;height: 50px; line-height:50px; vertical-align:middle;">
<div style="background-image:ur
to
<div style="background-image:ur