Mike_T
Posted
on Feb 27, 2011
(permalink)
Hello,
I was lookig at this example
http://demos.telerik.com/aspnet-ajax/rating/examples/gridrating/defaultcs.aspx
In order to update the database i inserted the ID column in the Grid, But i'm not sure what is the code that will allow me to retrieve the ID when i press to rate an item under this function
Protected Sub RadRating1_Rate(sender As Object, e As EventArgs)
Thanks much for your help
mike .'.
Reply
Niko
Niko
Posted
on Feb 28, 2011
(permalink)
Hello Mike,
First of all you should add a new column to the table. It can be a
DataBound column with Display set to false:
In the rate event handler get the
GridDataItem, as in the demo example, and use it as an indexed collection to get the text value of the column:
Hope this helps.
Kind regards,
Nikodim
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and
book your seat for a walk through all the exciting stuff we ship with the new release!
Reply
Mike_T
Posted
on Feb 28, 2011
(permalink)
Hey Nikodim,
I did exactly the same but i am getting an error in this:
'GridDataItem' is a type and cannot be used as an expression
Protected Sub RadRating1_Rate(ByVal sender As Object, ByVal e As EventArgs)
Dim oRating As RadRating = DirectCast(sender, RadRating)
Dim dataItem As GridDataItem = DirectCast(oRating.Parent.Parent, GridDataItem)
Dim x = Int32.Parse(GridDataItem("HymnID").Text)
........
End Sub
Thanks for your help
mike .'.
Reply
Niko
Niko
Posted
on Mar 1, 2011
(permalink)
Hi Mike,
You need to change the name of the variable to something other than GridDataItem. Otherwise the compiler cannot tell the variable from the type apart. You can, for example, change it to
gridDataItem or
currentDataItem.
All the best,
Nikodim
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and
book your seat for a walk through all the exciting stuff we ship with the new release!
Reply
Mike_T
Posted
on Mar 1, 2011
(permalink)
Hey Nikodim,
Thanks for your reply i'm still facing a problem in that declaration, can you please guide me more on how to do it?
i get the following error:
Unable to cast object of type 'Telerik.Web.UI.RadRating' to type 'Telerik.Web.UI.GridDataItem'.
Thanks,
mike .'.
Reply
Answer
Niko
Niko
Posted
on Mar 1, 2011
(permalink)
Hello Mike,
The sender parameter is actually a RadRating(keep in mind that you have attached to a RadRating event). The GridDataItem is a parent control of the parent control of the RadRating. Therefore the code should be the following:
This change should do it.
Best wishes,
Nikodim
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and
book your seat for a walk through all the exciting stuff we ship with the new release!
Reply
Mike_T
Posted
on Mar 1, 2011
(permalink)
that worked perfect, thank you so much Nikodim for your help
Mike .'.
Reply