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

How to Use Image Button as hyperlink

6 Answers 500 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AL
Top achievements
Rank 1
AL asked on 13 May 2008, 05:13 PM
How to use an Image button as a hyperlink in a radGrid?

I have a grid that displays customerID, firstname, lastname. The customerID field contains "View Details" image. When I click the "View Details" image button, I want the user to be redirected to: customerdetails.aspx?customerID = ALFKI

The following code does not work for an imageButton:-
CommandArgument="customerdetails.aspx?customerID=customerID.....does not work.

Appreciate your help.

Luv.

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2008, 06:32 AM
Hi Luv,

Try the following code snippet to achieve the desired scenario.

ASPX:
<telerik:GridTemplateColumn HeaderText="Temp" UniqueName="Temp" > 
                      <HeaderTemplate> 
                         <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/RadControls/Hay/Grid/AddRecord.gif" OnClick="ImageButton1_Click" /> 
                       </HeaderTemplate> 
   </telerik:GridTemplateColumn> 


CS:
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 
    { 
        Response.Redirect("~/customerdetails.aspx"); 
    } 


Thanks
Shinu.
0
AL
Top achievements
Rank 1
answered on 14 May 2008, 04:34 PM
Hi Shinu,

The code you are suggesting may work in older version of radGrid (2007), but not in 2008 Q1. I get error on ImageClickEventArgs e

I am trying to achieve the following action, but I get errors on CommandName and CommandArguments:--

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.CommandName == "viewdetails")
        {

            Response.Redirect("~/customerdetails.aspx?CustomerID=" + e.CommandArgument);

        }
    }


0
AL
Top achievements
Rank 1
answered on 14 May 2008, 05:29 PM
It seems Raju Kumar has the same request:--

Binding OnitemCommand event:

http://www.telerik.com/community/forums/thread/b311D-bdtmhb.aspx

ANy CORRECT and UPDATED telerik Grid documentation will be greatly appreciated. I downloaded the latest documentation, but it contains documentation for 2007 version???????
0
Sebastian
Telerik team
answered on 15 May 2008, 07:19 AM
Hello Luv,

The latest version of the online documentation of RadControls for ASP.NET AJAX can be found here:

http://www.telerik.com/help/aspnet-ajax/introduction.html

It will be updated by the end of the week along with the Q1 2008 SP1 release of the suite. CHM version of the documentation is also available for download at this location.

Regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mario
Top achievements
Rank 2
answered on 18 Jun 2009, 09:50 PM
hello,

im using the actual 2009 version of the radgrid but i still got that problem that i cant put objectinfo into my CommandArguments of my GridButtonColumn (ImageButton).

I red the actual online help to the template column @ http://www.telerik.com/help/aspnet-ajax/grdgettingstarted.html ,but i couldnt choose a field of my dataset, maybe cause i do not allow automatic column generation, because i defined all my columns myself.

So how get the via Linq's DAL Object Document.Metainformation.name via that code input ?! document is the table im selecting all on and metainformation is the next table where document got a foreign key from. there i have the name i want to use. so i can open a filepath via imagebutton.

thx mario
0
Karl
Top achievements
Rank 1
answered on 28 Oct 2010, 03:45 PM
I got around this issue by encoding an image into the Text property of the telerik:GridHyperLinkColumn like so...

<telerik:GridHyperLinkColumn
        Groupable="false"
        HeaderText="PDF"
        Text="<img src='../App_Themes/MyTheme/Images/SmallButtons/PDF-20x20.png' width='20' height='20' border='0' alt='' />"
        DataNavigateUrlFormatString="~/Info.aspx?id={0}"
        DataNavigateUrlFields="PDFLink"
        AllowFiltering="false" >
    <HeaderStyle HorizontalAlign="Center" Width="48px" />
    <ItemStyle HorizontalAlign="Center" Width="48px" />
</telerik:GridHyperLinkColumn>
Tags
Grid
Asked by
AL
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
AL
Top achievements
Rank 1
Sebastian
Telerik team
Mario
Top achievements
Rank 2
Karl
Top achievements
Rank 1
Share this question
or