Solved

convert repeater to listview.

Posted on 2010-08-14
4
516 Views
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">
        <HeaderTemplate>
            <table width="100%">
        </HeaderTemplate>
        <ItemTemplate>
            <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">
                            <%#DataBinder.Eval(Container,"DataItem.HeadLine")%></div>
                        <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" />
                            </a>
                        </div>
                        <div id="srcontent1">
                            <span class="srusername">
                                <%#DataBinder.Eval(Container,"DataItem.UserName")%></span>&nbsp;-&nbsp;<%#DataBinder.Eval(Container,"DataItem.Age")%>&nbsp;Years
                            Old&nbsp;
                            <%#DataBinder.Eval(Container,"DataItem.GenderName")%>
                            -&nbsp;<%#DataBinder.Eval(Container,"DataItem.ZodiacName")%>&nbsp;<asp:Image ID="imgZodiacSign"
                                ImageUrl='<%# GetUrl(Eval("ZodiacName")) %>' Style="vertical-align: middle" runat="server" /><br />
                        </div>
                        <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>
                        <div id="srcontent3">
                            <span class="srusername"></span>
                        </div>
                        <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 />
                        </div>
                    </div>
                </td>
            </tr>
            <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.ProfileID") %>' />
        </ItemTemplate>
        <FooterTemplate>
            </table>
            <br clear="All">
        </FooterTemplate>
    </asp:ListView>
0
Comment
Question by:omegalove
[X]
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
4 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 33440811
with ListView you should be using LayoutTemplate like below instead of Header and footer.
<LayoutTemplate>
    <table width="100%">
         <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
      </table>
            <br clear="All">
   </LayoutTemplate>
<itemTemplate>
   //your content as it is
</itemTemplate>
Check this example: http://www.4guysfromrolla.com/articles/010208-1.aspx
0
 

Author Comment

by:omegalove
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
0
 
LVL 41

Accepted Solution

by:
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.
}
0
 

Author Closing Comment

by:omegalove
ID: 33450932
k
0

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 & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, 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. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

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