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

[Solved] ImageButton in grid

1 Answer 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 26 Oct 2009, 06:49 AM
hi

I have a grid that display images using image button: I want to be able to retrieve the ID and a response.redirect when click. This is my code:
<ItemTemplate> 
                <asp:ImageButton ID="ImageButton1" runat="server"   
                    ImageUrl="~/image/first.png" /> 
                <br />&nbsp;&nbsp;&nbsp;  
                <asp:Label ID="BranchLabel" Width="150px" runat="server"   
                    Text='<%# Eval("Branch") %>' /> 
                <br /> 
                <br /> 
            </ItemTemplate> 

My Code Behind:

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
Dim imagebutton As ImageButton = TryCast(Page.Master.FindControl("RadGrid1"), ImageButton)  
End Sub  
 

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Oct 2009, 09:53 AM
Hello Lui,

Try the following approach:
Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
    If TypeOf e.Item Is GridDataItem Then
        Dim imgbut As ImageButton = TryCast(e.Item.FindControl("ImageButton1"), ImageButton)
    End If
End Sub

Let me know whether this helps.

Regards,
Daniel
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
L
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or