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

[Solved] Bring the Selected ID into CodeBehind SUB

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bernd Wachter
Top achievements
Rank 1
Bernd Wachter asked on 09 Nov 2009, 03:23 PM
Hello ,

I have a GridView in my Site

I will insert a Template or Button Column with a ImageButton in the Grid

When i click on this Button "Select" then i must Call a VB Sub

Private Sub BookingSelected()
Session Test("ID") = selectedID of the Row from my Grid

End Sub

How can i bring the Selected Row ID from my Grid to a Sub in my CodeBehind ????
I have a Column in my Grid where has the Name "ID"
and this ID Number of the Selected Row must i have in my Sub in Codebehind when i click the Select Button ?????

I must have this in Codebehind .. not another way

Thanks for Help



1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Nov 2009, 05:49 AM
Hello Bernd,

Try the following code snippet in order to get the value of selected row in ButtonClick event.

ASPX:
 
 <telerik:GridTemplateColumn> 
        <ItemTemplate> 
            <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Button" /> 
        </ItemTemplate> 
    </telerik:GridTemplateColumn> 

VB:
 
Protected Sub Button3_Click(ByVal sender As ObjectByVal e As EventArgs) 
    Dim btn As Button = DirectCast(sender, Button) 
    Dim item As GridDataItem = DirectCast(btn.NamingContainer, GridDataItem) 
    Dim id As String = item("ID").Text.ToString() 
    Response.Write(id) 
End Sub 

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