This is a migrated thread and some comments may be shown as answers.

[Solved] Selecting RadGrid Rows with LinkButton or ImageButton

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Terfa
Top achievements
Rank 1
Terfa asked on 23 Jan 2010, 08:01 PM
I'm wondering how can I resolve this problem?

I've written this piece of code to select row items on My RadGrid Control, which has the following select parameters...

SelectCommand="SELECT CityPinnacleDeals.DealID, CityPinnacleDeals.UserID FROM CityPinnacleDeals WHERE (CityPinnacleDeals.DealCategory <> 13) ORDER BY CityPinnacleDeals.DealID DESC"

The statement is valid and selecting the appropriate data, the RadGrid has created all the selected columns

RadGrid DataKeyNames="UserID, DealID"

The Code for selecting the rows is contained in the Linkbutton or Imagebutton Click event (both buttons are components of Template Columns added to the RadGrid Control) and is written thus...

Image Button
Protected Sub SelectGadgetFilterTwo_Click(ByVal sender As Object, ByVal e As System.EventArgs)




CType(CType(sender, ImageButton).Parent.Parent, GridItem).Selected = CType(sender, ImageButton).Visible
        RadGridFilterTwo_SelectedIndexChanged(sender, e)


End Sub

Link Button
Protected Sub SelectGadgetFilterTwo_Click(ByVal sender As Object, ByVal e As System.EventArgs)

CType(CType(sender, LinkButton).Parent.Parent, GridItem).Selected = CType(sender, LinkButton).Visible
        RadGridFilterTwo_SelectedIndexChanged(sender, e)


End Sub

The ImageButton contains images, while the Linkbutton contains the names of the displayed images, when either of the buttons is clicked, users are expected to be redirected to another page with the following code...,

Protected Sub RadGridFilterTwo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridFilterTwo.SelectedIndexChanged
       
Dim MyGadgetID As Integer = RadGridFilterTwo.SelectedItems(0).OwnerTableView.DataKeyValues(RadGridFilterTwo.SelectedItems(0).ItemIndex)("DealID")

Dim MyGadgetUserID As Integer = RadGridFilterTwo.SelectedItems(0).OwnerTableView.DataKeyValues(RadGridFilterTwo.SelectedItems(0).ItemIndex)("UserID")

Response.Redirect("GadgetsHome.aspx?.diresu=" & Str(StaffNumber.Text) & "&.diresulead=" & MyGadgetUserID & "&.dilead=" & MyGadgetID)


End Sub

but I keep receiving the error message...

"UserID is neither a DataColumn nor a DataRelation for table DefaultView"


Now I'm wondering how can I resolve this problem?



1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 27 Jan 2010, 07:48 AM
Hello Terfa,

To achieve the desired functionality, please refer to the following forum thread which elaborates on this subject.  
http://www.telerik.com/community/forums/aspnet-ajax/grid/selected-id-and-response-redirect.aspx

Give it a try and let me know if it works for you.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Terfa
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or