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

[Solved] could not get the value.

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

This is my code and i just couldn't get the value: I did a breakpoint at the ItemCommand  and the variable x is empty. Is there something wrong with this code? Thanks

 

<Columns>

 

 

<telerik:GridTemplateColumn DataField="CID" HeaderText="CID"

 

 

SortExpression="CID" HeaderStyle-Wrap="false" UniqueName="CID">

 

 

<ItemTemplate>

 

 

<asp:Label ID="CIDLabel" runat="server" Text='<%# Eval("CID") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<HeaderStyle Wrap="False"></HeaderStyle>

 

 

</telerik:GridTemplateColumn>

 

Protected

 

Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand

 

 

Dim item As GridDataItem

 

 

Dim x As String

 

 

 

 

 

If e.CommandName = "Select" Then

 

 

 

 

item =

DirectCast(e.Item, GridDataItem)

 

x = item(

"CID").Text

 

Session(

"cidl") = item("CID").Text

 

 

End If

 

 

 

 

 

End Sub

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Sep 2009, 08:15 AM
Hello,

You could access the Label control first and then get the value using the Text property of Label control as shown below.

VB:
 
Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) 
    If e.CommandName = RadGrid.SelectCommandName Then 
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
        ' Get the Label control in ItemTemplate 
        Dim lbl As Label = DirectCast(item.FindControl("CIDLabel"), Label)  
        ' Get the text 
        Dim x As String = lbl.Text.ToString() 
    End If 
End Sub 

-Shinu.
Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or