Wrox Programmer Forums
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2009, 04:31 PM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default ContentRating used in a datalist

Hi All,

My english is not very good, I will try to explain as clear as i can.

I used a content rating control (http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=410) in a datalist (the control is used inside the itemtemplate).

Here is part of my aspx code:

Code:
<asp:DataListID="dlResto"DataKeyField="IdResto"OnItemCreated="datalisthandlers"RepeatColumns="1"RepeatDirection="Vertical"runat="server">
<ItemTemplate>
<table>
<tr>
 <td>
   <b><%#Eval("Nom")%></b>&nbsp;&nbsp;
 </td>
</tr>
<tr>
<tdalign="right"valign="bottom">
  <isp:ContentRatingID="RestoRating"runat="server"     onrated="RestoRating_Rated"onrating="RestoRating_Rating"/>
 </td>
</tr>
</table>
</ItemTemplate>
And here is the code of the function : datalisthandlers

Code:
    protected void datalisthandlers(object sender, DataListItemEventArgs e)
    {
        //Rating Control Handler
        if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            if(e.Item.FindControl("RestoRating") != null)
            {
                ContentRating RestoRat = new ContentRating();
                RestoRat = (ContentRating) (e.Item.FindControl("RestoRating"));
                int[] arValues;
                Functions fct = new Functions();
                arValues = fct.GetRate(int.Parse(dlResto.DataKeys[e.Item.ItemIndex].ToString()));                RestoRat.ItemId = dlResto.DataKeys[e.Item.ItemIndex];
                RestoRat.DataSource = arValues; 
            }             
        }
    }
The stars are correctly displayed, but when I try to rate an item by clicking on one star, the control disappears after postback, and the evens RestoRating_Rated and RestoRating_Rating are not fired.

Can anyone please help me fix these issues?

Thanks a lot.
 
Old August 23rd, 2009, 05:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

As I suggested on my site, it probably has to do with your data binding. However, I don't see any of that code. Can you post the relevant parts of the code that triggers the data binding on the DataList so we can see when and where it's called?

Also, when you post code here, please use the Remove Text Formatting button on the toolbar. Color coded code does not - due to a nasty bug in this forum, end up right. Maybe you can edit your message and post it again?

Also, did you look at this?

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=465
http://imar.spaanjaars.com/Downloads...thRepeater.zip


Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
ilearn (August 24th, 2009)
 
Old August 24th, 2009, 12:39 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Many thanks, everything works just fine, the problem was in my page_load function, I didn't allow binding if the page was posted back. When I remove this, the RestoRating_Rated and RestoRating_Rating function started to be fired and the databind function let the stars appear.

Thank you so much, and BTW your control is great, keep doing such great job.

Tks
 
Old July 8th, 2011, 12:58 PM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by ilearn View Post
Hi Imar,

Many thanks, everything works just fine, the problem was in my page_load function, I didn't allow binding if the page was posted back. When I remove this, the RestoRating_Rated and RestoRating_Rating function started to be fired and the databind function let the stars appear.

Thank you so much, and BTW your control is great, keep doing such great job.

Tks
can you post your code? do you have your code on the page_load event for databind the cotrol?.... i am on the similar situation





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist inside datalist amit.jagtap ASP.NET 2.0 Professional 1 September 4th, 2007 05:03 AM
datalist sarah lee ASP.NET 1.0 and 1.1 Basics 0 October 18th, 2006 02:49 PM
Datalist cp75 ASP.NET 1.0 and 1.1 Professional 10 September 8th, 2006 11:38 AM
DataList in DataList acko ASP.NET 1.0 and 1.1 Professional 3 July 9th, 2004 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.