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

GridHyperLinkColumn or GridButtonColumn

3 Answers 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marta
Top achievements
Rank 1
Marta asked on 30 Apr 2009, 05:15 PM

Hi,

I am trying to add a column to my grid where there is a link to another page. For this, I have been using the GridHyperLinkColumn which does the job, but now instead of the text "View details" which I previously had as a hyperlink, I would like to place an icon (the same for every row in the grid). I tried with the GridHyperLinkColumn but I don't think it supports images. For this, I can only see using GridButtonColumn, but how do I insert the link with this type of column? The link is using the result from a select to detect the id of the content in order to form the url:

 

<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="/lms_bd/ContentDetails.aspx?content={0}" Target="_self" DataTextFormatString="my edit page" DataNavigateUrlFields="ContentID" UniqueName="ExternalEditLink" HeaderText="View Details" Text="View" >
</telerik:GridHyperLinkColumn>

In the .cs code of the ContentDetails.aspx page, the control literal1 receives the value passed in the url:

protected void Page_Load(object sender, EventArgs e)

{
string thisContent = Request.QueryString["content"].ToString();
Literal1.Text = thisContent;
}

I then use the following paramater in my select command:

<SelectParameters>
<asp:ControlParameter ControlID="Literal1" Name="content" PropertyName="Text" Type="String" />
</SelectParameters>

Does anyone have any suggestions?
Thanks!

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 04 May 2009, 08:27 AM
Hi Marta,

To achieve the desired functionality, I suggest that you use GridTemplateColumn with asp ImageButton inside it.
GridTemplateColumn displays each cell in the column in accordance with a specified template. This lets you provide custom controls in the column.

Please give a try of the code snippet bellow and let me know if it works for you.
ASPX:
<telerik:GridTemplateColumn HeaderText="View Details" UniqueName="ExternalEditLink">  
                        <ItemTemplate> 
                            <asp:ImageButton ID="ImageButton1" runat="server" PostBackUrl="~/Calendar/Default.aspx" 
                                ImageUrl="~/Common/Img/Icons/Grid.gif" /> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

For more information about column types, refer to the following articles:
Help topic
Demo

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Marta
Top achievements
Rank 1
answered on 04 May 2009, 09:30 AM
Hi! Thanks for your reply! I still have a problem though. The solution you offered does not work for the postbackurl, since I am using the result of the query to retrieve the contentID which is part of the url. With the GridHyperlinkColumn, I had:

<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="/lms_bd/ContentDetails.aspx?content={0}" Target="_self" DataTextFormatString="my edit page" DataNavigateUrlFields="ContentID" UniqueName="ExternalEditLink" HeaderText="View Details" Text="View" >
</telerik:GridHyperLinkColumn>

but with the GridTemplateColumn, the DataNavigateUrlFields does not exist, and is necessary so that I can form the url using the contentID. Any ideas?

Thanks a lot.
0
Pavlina
Telerik team
answered on 07 May 2009, 05:39 AM
Hello Marta,

In order to progress in the resolution of this matter, I will ask you to open a formal support ticket and send us a small runnable application, so we can check it locally. As soon as I have an answer I will get back to you.

Thank you for your cooperation in advance.

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Marta
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Marta
Top achievements
Rank 1
Share this question
or