convert repeater to listview.

Posted on 2010-08-14
Medium Priority
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: http://www.4guysfromrolla.com/articles/010208-1.aspx

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 2000 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

770 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