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 .'.
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 .'.
6 Answers, 1 is accepted
0
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
First of all you should add a new column to the table. It can be a DataBound column with Display set to false:
<
telerik:GridBoundColumn
UniqueName
=
"DB_ID_Column"
DataField
=
"ID"
Display
=
"false"
/>
Int32.Parse(gridDataItem(
"DB_ID_Column"
).Text)
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!
0
Mike_T
Top achievements
Rank 1
answered on 28 Feb 2011, 11:14 PM
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
Thanks for your help
mike .'.
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 .'.
0
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
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!
0
Mike_T
Top achievements
Rank 1
answered on 01 Mar 2011, 10:57 AM
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 .'.
Thanks for your reply i'm still facing a problem in that declaration, can you please guide me more on how to do it?
Dim
currentDataItem
As
GridDataItem =
DirectCast
(sender, GridDataItem)
Dim
x = Int32.Parse(currentDataItem(
"HymnID"
).Text)
i get the following error:
Unable to cast object of type 'Telerik.Web.UI.RadRating' to type 'Telerik.Web.UI.GridDataItem'.
Thanks,
mike .'.
0
Accepted
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
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:
Dim
currentDataItem
As
GridDataItem =
DirectCast
(sender.Parent.Parent, GridDataItem)
Dim
x = Int32.Parse(currentDataItem(
"HymnID"
).Text)
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!
0
Mike_T
Top achievements
Rank 1
answered on 01 Mar 2011, 01:15 PM
that worked perfect, thank you so much Nikodim for your help
Mike .'.
Mike .'.