Problem with CSS(floating) in ListView ItemTemplate! - asp.net

i am new in CSS and have a problem with styling ListView Control in ItemTemplate tag.
my project language is rtl(persian) and i want to set the user image at the right and her/his infos to the left of the image.
but this is the result:
alt text http://sites.google.com/site/mahdiahmadirad/download-1/2009-12-08_134217.png?attredirects=0&d=1
and here is the code for ListView:
<asp:ListView ID="NokListView" runat="server" DataSourceID="ObjectDataSource1">
<LayoutTemplate>
<img alt="" src="./img/group.png"><br />
<br />
<fieldset>
<legend>ليست کلي</legend>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</fieldset>
</LayoutTemplate>
<ItemSeparatorTemplate>
<hr />
</ItemSeparatorTemplate>
<ItemTemplate>
<img style="float: right;" alt="" src='<%# Eval("Gender","./img/{0}.png") %>' />
<span>نام وارث:</span><%# Eval("FirstName") %> <%# Eval("LastName") %><span
dir="ltr">(<%# Eval("Email") %>)</span><br />
<span>نسبت او با شما:</span>
<%# Eval("Relationship")%><br />
</ItemTemplate>
</asp:ListView>
I set the style of to float:right and it is working but as you see the template is like a Hierarchical list!
I want each Item place below the previous Item NOT in the front of.
please explain me what is exactly happening?! and how to fix it?

Put the non-image data together in a div with float:left and see if that works?

I Found My Answer here: doctype.com
and the complete fixed code is:
<ItemSeparatorTemplate>
<hr style="clear:right;" />
</ItemSeparatorTemplate>
<ItemTemplate>
<div style="clear: both;">
<img style="float: right;" alt="" src='<%# Eval("Gender","./img/{0}.png") %>' />
<span>نام وارث:</span><%# Eval("FirstName") %> <%# Eval("LastName") %>
<span dir="ltr">(<%# Eval("Email") %>)</span><br />
<span>نسبت او با شما:</span><%# Eval("Relationship")%><br />
</div>
</ItemTemplate>
So Look at the result:
alt text http://sites.google.com/site/mahdiahmadirad/download-1/2009-12-09_103134.png?attredirects=0&d=1

Related

Changing the order of components doesn't yield desired result

I have been trying to get the "Contact Us" part of this aspx to show up after the "Custom dial" part, but for some reason no matter what I try the custom dial is appearing after, not before. Does anyone know what I need to do to get the contact us link to move to the right side of the custom dial? This is driving me crazy.
<div style="clear: both;">
<asp:Panel ID="pnlLogo" runat="server" Visible="false" CssClass="logo_holder">
<asp:HyperLink runat="server" ID="LogoLink">
<asp:Image ID="imgLogoAdm" CssClass="logo" ImageUrl="~/Images/CompanyLogo.png" runat="server" />
</asp:HyperLink>
<span class="slogan"><strong>This is <br />
Our Motto</strong></span>
<span>
<br />
<asp:Label ID="Label1" runat="server" Width="25px"> </asp:Label>
<asp:HyperLink runat="server" ID="CustomDialHyperlink">
<asp:Image runat="server" ID="imgCustomDial" Width="160px" Height="80px" Visible="false" />
</asp:HyperLink>
</span>
<span class="contact_info">
<asp:HyperLink ID="ContactUs" NavigateUrl="~/ContactUs.aspx" runat="server"><strong>Contact Us</strong></asp:HyperLink>
</span>
</asp:Panel>
</div>
Thanks

ASP.Net ListView Grouping by Data Field?

I uses asp.net listview control to display the details. Each item has the group details. For demo purposes group is hard coded.
I want to display the listview as shown below
Right now, I have this
Code:
<asp:ListView ID="HyperLinkListView" runat="server" ViewStateMode="Disabled" ItemPlaceholderID="itemContainer" GroupPlaceholderID="groupContainer">
<LayoutTemplate>
<section class="quick-links">
<div class="row">
<div class="dfwp-column" style="width: 100%">
<div class="slm-layout-main groupmarker">
<ul class="dfwp-list">
<asp:PlaceHolder ID="groupContainer" runat="server" />
</ul>
</div>
</div>
</div>
</section>
</LayoutTemplate>
<GroupTemplate>
<span>Group</span>
<asp:PlaceHolder ID="itemContainer" runat="server" />
</GroupTemplate>
<ItemTemplate>
<li>
<div class="item">
<div class="link-item">
<asp:HyperLink Target="_blank" ID="hyperlink" NavigateUrl='<%# this.LinkToPlay((((SPListItem)Container.DataItem)["VideoFileName"]).ToString()) %>' Text='<%# Eval("Title") %>' runat="server" />
</a>
</div>
</div>
</li>
</ItemTemplate>
<EmptyDataTemplate>
<span>No data was returned.</span>
</EmptyDataTemplate>
</asp:ListView>
How do I achieve this?
For a flexible solution, you can use nested ListView
You will need to update your HTML and CSS to get the desired appearance.
ASPX Code
<asp:ListView ID="GroupsListView" runat="server" ViewStateMode="Disabled" ItemPlaceholderID="groupContainer" OnItemDataBound="GroupsListView_ItemDataBound">
<LayoutTemplate>
<section class="quick-links">
<div class="row">
<div class="dfwp-column" style="width: 100%">
<div class="slm-layout-main groupmarker">
<asp:PlaceHolder ID="groupContainer" runat="server" />
</div>
</div>
</div>
</section>
</LayoutTemplate>
<ItemTemplate>
<ul class="dfwp-list">
<li><%# Eval("Title") %></li>
<div>
<asp:ListView runat="server" ID="ItemsListView" ItemPlaceholderID="itemContainer">
<LayoutTemplate>
<section class="quick-links">
<div class="row">
<div class="dfwp-column" style="width: 100%">
<div class="slm-layout-main groupmarker">
<ul class="dfwp-list">
<asp:PlaceHolder ID="itemContainer" runat="server" />
</ul>
</div>
</div>
</div>
</section>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="item">
<div class="link-item">
<asp:HyperLink Target="_blank" ID="hyperlink" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>' runat="server" />
</a>
</div>
</div>
</li>
</ItemTemplate>
</asp:ListView>
</div>
</ul>
</ItemTemplate>
<EmptyDataTemplate>
<span>No data was returned.</span>
</EmptyDataTemplate>
</asp:ListView>
In the code behind you need to bind the child ListView in parent ItemDataBound event.
protected void GroupsListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
ListView itemsListView = (ListView)e.Item.FindControl("ItemsListView");
if (e.Item.ItemType == ListViewItemType.DataItem)
{
itemsListView.DataSource = ((Group)e.Item.DataItem).Items;
itemsListView.DataBind();
}
}
It is not quite clear what kind of grouping you want. However the ListView is limited in what it can do.
First of all you can only get a grouping by a fixed number of items. You can define that number with the GroupItemCount property. Your code would then look like this
<asp:ListView ID="HyperLinkListView" GroupItemCount="2" runat="server" ViewStateMode="Disabled" ItemPlaceholderID="itemContainer" GroupPlaceholderID="groupContainer">
And generate in html like this
GROUP
My car video
My sample video
GROUP
Another sample video
Item 4
Assuming you want GROUP A and GROUP B etc, you would normally use a binding expression, which looks like this
<GroupTemplate>
<span>Group <%# Container.DataItemIndex %></span>
<asp:PlaceHolder ID="itemContainer" runat="server" />
</GroupTemplate>
However the GroupItemTemplate is not part of the DataBind process, so getting and index based system will not work like that.
So a client side solution is needed if you want to add A, B etc. So first add a placeholder for the alhpa character and give the <span> a class so jQuery can find it. I've used {index} and groupIndex
<GroupTemplate>
<span class="groupIndex">Group {index}</span>
<asp:PlaceHolder ID="itemContainer" runat="server" />
</GroupTemplate>
Now with a simple jQuery method, all the placeholders are replaced with their correct alpha character.
<script type="text/javascript">
$(document).ready(function () {
$('.quick-links .groupIndex').each(function (index, element) {
var char = String.fromCharCode(65 + index);
$(this).html($(this).html().replace('{index}', char));
});
});
</script>
Note that the .quick-links comes from your <section class="quick-links"> part in the LayoutTemplate.

overflow:hidden makes data disappear in IE

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") %>' />&#8364
</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;
}

How to add slider in datalist controll

I want to add slider in datalist controll.
<ItemTemplate>
<img alt="" src='Image/<%#Eval("Image") %>' /><br />
</a>
<h4><asp:Label ID="lb" runat="server" Font-Bold="True" Font-Size="12pt" Text='<%# Eval("Title") %>'></asp:Label><br />
Product Code: <span><%# Eval("product_code") %></span></h4>
<span ><del>र</del><%# Eval("Our_price") %>INR</span><br />
<a href='Shopping_Cart.aspx?cart_id=<%# Eval("id") %>'>Add to Cart</a>
Now I want to add slider so that all products could slide with images.
Your Question was not Clear what i understood is that u want to scroll your item list. Give your Datalist a fixed size(height and width) and overflow:scrolling in css
style='height:400;width:500; overflow:scrolling'
I understood that you can do it dynamically.You can use image slider into datalist as below:
<div id="box">
<div id="slider">
<div class="slider">
<ul>
<asp:DataList ID="DataList1" runat="server" RepeatColumns="7" RepeatDirection="Horizontal">
<ItemTemplate>
<li><img src='<%#Eval("Path") %>' alt="" width="272" height="170" runat="server"/></li>
</ItemTemplate>
</asp:DataList>
</ul>
</div>
<div class="sliderButon">
Previous
Next
</div>
</div>
</div>

How to make a Faq page like this in Asp.net

I would like to make a FAQ page similar to here: Forum FAQ
using an sql database. Does anyone have any ideas?
create table faq_questions and add there questions,
table structure:
categorie, question, answer
and the read that data to website, what programming language you are using?
this is the final answer for my own question. Here it is it
<asp:Repeater id="faqCategoryList" runat="server">
<HeaderTemplate>
<h4>
Frequently Asked Questions</h4>
</HeaderTemplate>
<ItemTemplate>
<a href='#<%# Eval("FAQCategoryCode")%>' class="lnkButton">
<%# Eval("CategoryName")%>
</a>
</ItemTemplate>
<SeparatorTemplate>
<hr class="dashed" />
</SeparatorTemplate>
<FooterTemplate>
<div style="margin-bottom: 30px;">
</div>
</FooterTemplate>
</asp:Repeater>
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<fieldset id='<%# ((System.Data.DataRowView)Container.DataItem)["FAQCategoryCode"]%>'>
<legend><span style="font-size: medium; font-weight: bold;">
<%# ((System.Data.DataRowView)Container.DataItem)["CategoryName"]%>
</span></b> </legend>
<asp:Repeater id="Repeater2" datasource='<%# ((System.Data.DataRowView)Container.DataItem).CreateChildView("FaqRelation")%>'
runat="server">
<ItemTemplate>
<div style="font-weight: bold;">
<%# ((System.Data.DataRowView)Container.DataItem)["Question"]%>
</div>
<br />
<%#((System.Data.DataRowView)Container.DataItem)["Answer"]%>
<br />
<br />
</ItemTemplate>
<SeparatorTemplate>
<hr class="dashed" />
</SeparatorTemplate>
<FooterTemplate>
<a href="javascript:scroll(0,0)" style="float: right">
<img src="Images/png/icon_back_top.gif" class="lnkButton" alt="top" />Top</a>
</FooterTemplate>
</asp:Repeater>
</fieldset>
</ItemTemplate>
<FooterTemplate>
<br />
</FooterTemplate>
</asp:Repeater>

Resources