convert repeater to listview.

Posted on 2010-08-14
Last Modified: 2012-05-10
I need to convert the folllowing to work as a list view. I tried it out
and have problems.
HeaderTemplate and  FooterTemplate are giving me problems.

 <asp:ListView ID="lvList" runat="server" OnItemDataBound="lvList_ItemDataBound">
            <table width="100%">
            <tr onclick="testRedirect('<%#GetRedirectUrl(Eval("UserName").ToString(), Eval("ProfileID").ToString() )%>')" style="cursor: pointer"
                onmouseover="style.backgroundColor='LightBlue'" onmouseout="style.backgroundColor=''">
                <td align="center">
                    <div id="srdiv">
                        <div id="srtitle">
                        <br />
                        <div id="srpicdiv">
                            <a id="HLMainPicID" runat="server" navigateurl='<%#"~/Secure/UserProfile.aspx?FromUserName="+Eval("UserName") + "&UserFromProfileID=" + Eval("ProfileID") %>'>
                                <asp:Image ID="MainPicID" Style="vertical-align: middle" class="srpic" runat="server" />
                        <div id="srcontent1">
                            <span class="srusername">
                            -&nbsp;<%#DataBinder.Eval(Container,"DataItem.ZodiacName")%>&nbsp;<asp:Image ID="imgZodiacSign"
                                ImageUrl='<%# GetUrl(Eval("ZodiacName")) %>' Style="vertical-align: middle" runat="server" /><br />
                        <div id="srcontent2">
                            <span class="srcategories">Seeking:&nbsp;</span><%#DataBinder.Eval(Container,"DataItem.SeekingName")%>&nbsp;between&nbsp;
                            <%#DataBinder.Eval(Container, "DataItem.StartAge")%>&nbsp;-&nbsp;<%#DataBinder.Eval(Container, "DataItem.EndAge")%><br />
                            <span class="srcategories">From:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.CityName")%>,&nbsp;<%#DataBinder.Eval(Container,"DataItem.RegionName")%>,
                            &nbsp;<%#DataBinder.Eval(Container,"DataItem.Country")%><br />
                            <span class="srcategories">Body Type:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.BodyTypeName")%><br />
                            <span class="srcategories">Hair Color:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.HairColorName")%><br />
                            <span class="srcategories">Eye Color:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.EyeColorName")%><br />
                            <span class="srcategories">Height:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.HeightName")%><br />
                            <span class="srcategories">Occupation:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.OccupationName")%><br />
                            <span class="srcategories">Education:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.EducationName")%><br />
                        <div id="srcontent3">
                            <span class="srusername"></span>
                        <div id="srcontent4">
                            <span class="srcategories">Marital Status:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.MaritalStatusName")%><br />
                            <span class="srcategories">Have Children:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.HaveChildrenName")%><br />
                            <span class="srcategories">Want Children:</span>&nbsp;<%#DataBinder.Eval(Container, "DataItem.WantChildrenName")%><br />
                            <span class="srcategories">Ethnicity:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.EthnicityName")%><br />
                            <span class="srcategories">Religion:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.ReligionName")%><br />
                            <span class="srcategories">Alcohol:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.DrinkingName")%><br />
                            <span class="srcategories">Smoking:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.SmokingName")%><br />
                            <span class="srcategories">Drugs:</span>&nbsp;<%#DataBinder.Eval(Container,"DataItem.DrugName")%><br />
            <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.ProfileID") %>' />
            <br clear="All">
Question by:omegalove
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
LVL 41

Expert Comment

ID: 33440811
with ListView you should be using LayoutTemplate like below instead of Header and footer.
    <table width="100%">
         <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
            <br clear="All">
   //your content as it is
Check this example:

Author Comment

ID: 33443124
if ((e.Item.ItemType == ListItemType.Item) ||
               (e.Item.ItemType == ListItemType.AlternatingItem)) // Get Primary Image

from a repeater to listview

  // make sure this is an item in the data list (not header etc.)
            if ((e.Item.ItemType == ListViewItemType.Item) ||
                (e.Item.ItemType == ListViewItemType.AlternatingItem)) // Get Primary Image

Error      3      'System.Web.UI.WebControls.ListViewItemType' does not contain a definition for 'Item'      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Secure\WhosOnline.aspx.cs      77      54      OmegaLove.Web
Error      4      'System.Web.UI.WebControls.ListViewItemType' does not contain a definition for 'AlternatingItem'      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Secure\WhosOnline.aspx.cs      78      54      OmegaLove.Web
LVL 41

Accepted Solution

guru_sami earned 500 total points
ID: 33446286
check like this:
//no need of alternatingItem, just DataItem

if (e.Item.ItemType == ListViewItemType.DataItem)
 //your code.

Author Closing Comment

ID: 33450932

Featured Post

Independent Software Vendors: 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

I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

726 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