I'm having a problem with IE. The page works fine in all browsers like shown below.
but in IE the data doesn't show up even though its there.
The problem is caused by the overflow:hidden attribute I use on the item template of the ListView. When I change it to any other value the data shows up in IE but of course the layout gets messed up in all browsers.
Here is the source code and the CSS http://jsfiddle.net/V5aCa/8/
And here is my code:
<asp:ListView ID="BookListView" runat="server" DataSourceID="SqlDataSource1"
onselectedindexchanged="BookListView_SelectedIndexChanged">
<LayoutTemplate>
<table runat="server" cellpadding="1" id="tblBooks" style="">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<div style="overflow:hidden">
<div class="itemTemplateleftColumn">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# String.Format("~\\Static\\Images\\BookCovers\\{0}", Eval("CoverImageSmall")) %>' Height="120px" Width="90px" BorderColor="Gray" BorderWidth="1px"/>
</div>
<div class="itemTemplaterightColumn">
<div class="titleRow">
<asp:Label runat="server" ID="BookTitleLabel" Text='<%# Eval("Title") %>' />
</div>
<div class="nameRow">
<asp:Label runat="server" ID="FirstNameLabel" Text='<%# Eval("FirstName") %>' />
<asp:Label runat="server" ID="LastNameLabel" Text='<%# Eval("LastName") %>' />
</div>
<div class="values">
<div>
value1
</div>
<div>
value2
</div>
</div>
<div class="values">
<div>
value3
</div>
<div>
<asp:Label runat="server" ID="PriceLabel" Text='<%# Eval("Price") %>' />€
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</asp:Content>
I would appreciate any help on solving this issue. Thanks in advance.
Apply minimum Height and Width for that div in Gridview and then apply overflow
min-height: 110px;min-width: 150px;
Try this hope it will help!
[Updated] First, apply a css class or id to avoid inline styling.
Then, try to write overflow:hidden !important to prevent IE from applying that rule, this should do the trick!
.your-div-class{
overflow:visible; /* This is default value, but reset it anyway */
overflow:hidden !important;
}
Related
I'm trying to fit a GridView (or a ListView, I've tried both) into the panel-body of a div panel. However, whenever the GridView appears, it closes out the panel-body early and causes formatting issues.
I've tried GridView, ListView, rearranging the elements of my panel, and I've trimmed a lot of stuff back to get it down to just the GridView.
<asp:ListView ID="lvOuter" runat="server" ItemPlaceholderID="placeHolder" DataKeyNames="PkUser" OnItemCommand="lvOuter_ItemCommand" OnSorting="lvOuter_Sorting" OnSelectedIndexChanging="lvOuter_SelectedIndexChanging" OnPagePropertiesChanging="lvOuter_PagePropertiesChanging">
<LayoutTemplate>
<table style="border-collapse: collapse; width: 100%">
<tbody>
<tr id="placeHolder" runat="server" style="width: 100%"></tr>
</tbody>
<tfoot>
<tr style="align-content: center;">
<td class="listViewFooterText" style="color: white; text-align: center">
<uc:listviewpager runat="server" id="ucOuterListViewPager" listviewcontrolid="lvOuter" />
</td>
</tr>
</tfoot>
</table>
</LayoutTemplate>
<ItemTemplate>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<span class="glyphicon glyphicon-user x1" style="text-align: left;" />
<b>
<asp:Label ID="lbEmployeeTitle" runat="server" Style="font-family: Arial; font-size: 14px;" Text='<%# Eval("EmployeeName") %>'></asp:Label></b>
<asp:Label ID="lbUnapprovedTitle" runat="server" CssClass="badge badge-blue" Text='<%# Eval("TotUnapproved") %>'></asp:Label>
</h3>
</div>
<div class="panel-body">
<asp:GridView ID="gvInner" runat="server" DataSource='<%# Eval("IndividualTracking") %>' AutoGenerateColumns="false" DataKeyNames="PkTrainingRequest" OnRowCommand="gvInner_RowCommand">
<Columns>
<asp:TemplateField ItemStyle-Width="40%" HeaderText="Title">
<ItemTemplate>
<asp:LinkButton ID="kbTitle" runat="server" CssClass="gridViewRowText" CommandName="Populate" ToolTip="Go to Training Request" Text='<%# Eval("Title") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="20%" HeaderText="Length">
<ItemTemplate>
<asp:LinkButton ID="kbLength" runat="server" CssClass="gridViewRowText" CommandName="Populate" ToolTip="Go to Training Request" Text='<%#Eval("Length") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="30%" HeaderText="Date">
<ItemTemplate>
<asp:LinkButton ID="kbDate" runat="server" CssClass="gridViewRowText" CommandName="Populate" ToolTip="Go to Training Request" Text='<%#Eval("Date") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="Approve">
<ItemTemplate>
<asp:Button ID="btnQuickApprove" runat="server" Text="Quick Approve" CssClass="btn btn-success" CommandName="Approve" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div class="panel-footer">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-2">
<asp:Button ID="btnDrillDown" Text='<%#Eval("Subordinates") %>' CommandName="DrillDown" CssClass="btn btn-primary" runat="server" Visible='<%#Eval("VisibleSubordinates") %>' />
</div>
<div class="col-md-2">
</div>
<div class="col-md-2">
<asp:Button ID="btnViewTraining" Text="View All Training" CommandName="ViewTraining" CssClass="btn btn-primary" runat="server" />
</div>
<div class="col-md-4"></div>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
Expected result: panels, each with a header and footer, and a gridview (when it populates) in the body.
Actual result: the panels work fine until the gridview populates. When that happens, the panel-body ends before the gridview, and the panel-footer attaches to the top of the next panel.
You made a tr the placeHolder. So it generates this, which is incorrect html
<table style="border-collapse: collapse; width: 100%">
<tbody>
<div class="panel panel-default">
xxx
</div>
So if you want to use a correct table, make the LayoutTemplate like this
<asp:ListView ID="lvOuter" runat="server" ItemPlaceholderID="placeHolder">
<LayoutTemplate>
<table style="border-collapse: collapse; width: 100%">
<tbody>
<tr>
<td>
<span id="placeHolder" runat="server"></span>
</td>
</tr>
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<div class="panel panel-default">
</div>
</ItemTemplate>
</asp:ListView>
Which generates
<table>
<tbody>
<tr>
<td>
<div class="panel panel-default">
</div>
<div class="panel panel-default">
</div>
</td>
</tr>
</tbody>
</table>
This still places everything in a single table cell. If you want a cell per ItemTemplate you need to put <tr><td> in it.
I have a repeater set up in Visual Studio to try and grab the latest 3 blog titles from the database and show the associated image along with the title, intro and a link.
However the parent div of each blog needs to have a different ID.
Currently I have the following code but it's not working because I've since found out you can't have an itemtemplate followed by an alternating item template followed by another item template.
I there any workaround to this?
<asp:Repeater runat="server" ID="repeaterNews1" DataSourceID="SQLDataNews1">
<ItemTemplate>
<div id="blog1">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image1" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div id="blog2">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image2" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</AlternatingItemTemplate>
<ItemTemplate>
<div id="blog3">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image3" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
No, you cannot create a third template.
What you can do is make sure the ID's are still unique by using Container.DataItemIndex
<ItemTemplate>
<div id="blog<%# Container.DataItemIndex %>"></div>
</ItemTemplate>
I have the following Listview in my aspx page
<asp:ListView ID="ListView1" GroupItemCount="4" runat="server"
DataKeyNames="contentid" DataSourceID="sqldsPhotos">
<LayoutTemplate>
<asp:Placeholder
id="groupPlaceholder"
runat="server" />
</LayoutTemplate>
<GroupTemplate>
<div>
<asp:Placeholder
id="itemPlaceholder"
runat="server" />
</div>
</GroupTemplate>
<ItemTemplate>
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" />
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
<EmptyItemTemplate>
</EmptyItemTemplate>
</asp:ListView>
The resulting webpage displays my image with the link button beside it. What I would like is the image with the Linkbutton centered below it for each item.
Can someone help me out with the necessary html or css to achieve this.
Try the following html inside ItemTemplate
<div style="float: left; margin-left: 10px; text-align:center;width: 192; ">
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" />
<asp:LinkButton ID="LinkButton1" runat="server"
style="display: block; clear: both;">LinkButton</asp:LinkButton>
</div>
The above code will show divs side by side. So inorder to show 4 divs add with (800px) to your items in list view.
If you don't get the linkbutton at center add some margin-left to it to show it at center.
Try this:
<div style="width: 192px; text-align:center;">
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" /><br/>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</div>
I've got an alignment issue:
What I need is for the 'Delete Reasons' text to be vertically aligned, centered with the red 'X'. I tried using a div tag with CSS and style="verticalalign: middle;" but it forced 'Delete Reasons' to go underneath the 'X'.
How can I vertically center the text? Any help is greatly appreciated!
PS - Here's the code:
<tr>
<td class="style7" valign="middle">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ImageButton ID="ibClearReasons" runat="server" Height="30px" Width="30px" ImageUrl="~/Images/DeleteRed.png" AlternateText="Delete" />Delete Reasons
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td class="style6">
<asp:LinkButton ID="SendToBatch" runat="server" BackColor="#20548E" BorderColor="#20548E" BorderStyle="Solid" Font-Names="Tahoma" Font-Size="Small" Font-Underline="False"
ForeColor="White" Height="16px" Width="85px" EnableViewState="True" CausesValidation="False"><center>Send To Batch</center></asp:LinkButton>
</td>
</tr>
EDIT: CSS Style 7:
.style7
{
text-align: left;
vertical-align: middle;
}
You have to set the vertical-align attribute on the element: http://jsfiddle.net/rkw79/Zs5AH/
There is a good chance that it will still look off if the img height is small. For issues like that, you would need to wrap 'delete reasons' inside a <span> tag and give it a padding-top attribute.
Try this...
<td class="style7" valign="middle">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="float:left;margin:0px 4px;width:30px;">
<asp:ImageButton ID="ibClearReasons"
runat="server"
Height="30px"
Width="30px"
ImageUrl="~/Images/DeleteRed.png"
AlternateText="Delete" />
</div>
<div style="float:left;height:30px;padding:6px 0px;width:100px;">
Delete Reasons
</div>
<div style="clear:both"></div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
You may have to play with the padding and/or width on the second div to get it to be just right. If this works, you can simply move the inline styles to a css file with class names (div.className) HTH
I've got a problem here with a div not being placed that way I'd like it to.
This is the ASP code I'm using:
<asp:ListView ID="categoriesListView" runat="server">
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" class="sub" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</ItemTemplate>
</asp:ListView>
I was expecting results like this:
<div class="main">
<div class="sub">
...
</div>
<div class="sub">
...
</div>
<div class="sub">
...
</div>
...
</div>
The result was one big div "main" containing everything, with no "sub" divs.
If I added the itemPlaceholder one level deeper, the same thing would happen, now with 1 "sub" div and everything pushed in there. How do I solve this?
Change it to look like this:
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<div class="sub" >
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</div>
</ItemTemplate>