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

select command and griddataitem

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 07 Sep 2010, 09:13 AM
hi

i have on my aspx page a select command:

  <telerik:GridButtonColumn CommandName="Select" DataTextField="ZipCode"
            HeaderText="Zipl Code"  Text="Zip Code" UniqueName="ZipCode">
        </telerik:GridButtonColumn>

I am trying to pass the value of zip code a session but is empty. Zip code is not a primary key and i can see the zip code display in the grid. How do get the zip code value? thanks

If e.CommandName = "Select" Then
Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
            Session("zipcode") = selectedRow("zipcode").Text

End if

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Sep 2010, 09:41 AM
Hello,

Since 'zipcode' is a GridButtonColumn, access the control first and then get the text like below.

VB.Net:
Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs)
    If e.CommandName = "Select" Then
        Dim selectedRow As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim btn As LinkButton = DirectCast(selectedRow("zipcode").Controls(0), LinkButton)
        Session("zipcode") = btn.Text
    End If
End Sub

Thanks,
Princy.
Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or