DEVANG SHARMA
DEVANG SHARMA

Reputation: 2662

Insert Hyperlinks in the Telerik GridView of .net

I made a .net application which uses the Telerik components,

so i use the grid view of telerik, now I want to use the Hyperlinks in Telerik but how i can do this,

I am familiar with the ActionLinks in the Telerik,

But now want to implement the Hyperlinks in Telerik.

Upvotes: 0

Views: 4942

Answers (3)

Bobby
Bobby

Reputation: 1604

Something like this will work for you

<radg:RadGrid ID="RadGrid1" runat="server" CssClass="RadGrid" Width="95%" AutoGenerateColumns="False"
    PageSize="7" AllowPaging="True" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView>
        <Columns>
            <radg:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title" />
            <radg:GridHyperLinkColumn DataTextField="City" DataNavigateUrlField="City" DataNavigateUrlFormatString="http://www.google.com/search?q={0}" />
        </Columns>
    </MasterTableView>
</radg:RadGrid>

EDIT

You can add the GridHyperLinkColumn dynamically from code behind like this.

GridHyperLinkColumn hyperLinkColumn = new GridHyperLinkColumn();
RadGrid1.Columns.Add(hyperLinkColumn);
hyperLinkColumn.DataTextField = "City";
hyperLinkColumn.DataNavigateUrlField = "City";
hyperLinkColumn.DataNavigateUrlFormatString = "http://www.google.com/search?q={0}";

Upvotes: 2

James Johnson
James Johnson

Reputation: 46067

With the RadGrid you basically have two options: GridHyperLinkColumn or GridTemplateColumn.

GridHyperLinkColumn

<telerik:GridHyperLinkColumn 
    DataNavigateUrlFormatString="/somepage.aspx?foo={0}&bar={1}"
    DataNavigateUrlFields="Column1, Column2"             
    DataTextField="Column3">
</telerik:GridHyperLinkColumn>

GridTemplateColumn

<telerik:GridTemplateColumn HeaderText="Foo">
    <ItemTemplate>            
        <asp:HyperLink ID="HyperLink1" runat="server" Text="Details" NavigateUrl='<%#String.Format("/somepage.aspx?foo={0}&bar={1}", Eval("Column1"), Eval("Column2"))%>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>

Upvotes: 3

Icarus
Icarus

Reputation: 63964

You can use GridHyperLinkColumns if you are talking about having links inside the Grid. It's not very clear from your question.

 <telerik:GridHyperLinkColumn FooterText="HyperLinkColumn footer" DataTextFormatString="Search Google for '{0}'"
  DataNavigateUrlFields="CompanyName" UniqueName="CompanyName" DataNavigateUrlFormatString="http://www.google.com/search?hl=en&amp;q={0}&amp;btnG=Google+Search"
  HeaderText="HyperLink<br/>Column" DataTextField="CompanyName">

As far as regular hyperlink control; Telerik doesn't have one. You can use the normal <asp:Hyperlink ../> control

Upvotes: 2

Related Questions