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

[Solved] Radgrid binding with an array

2 Answers 385 Views
Grid
This is a migrated thread and some comments may be shown as answers.
anna
Top achievements
Rank 1
anna asked on 04 May 2008, 02:00 AM
I am working on a web application.  My data comes in a complicated format thats why I save it to an array first and then I am creating a datatable so that I can bind it with my grid. Can you tell me how to make a datatable column a hyperlink. Following is not the actual code but logic is same
:
Code:
Dim id(2) As String Dim desc(2) As String 'declaring an array id(0) = "1" id(1) = "2" desc(0) = "Soccer" desc(1) = "Cricket" Dim dt As New Data.DataTable Dim dr As Data.DataRow Dim i As Integer dt.Columns.Add(New Data.DataColumn("ID", GetType(String))) dt.Columns.Add(New Data.DataColumn("Desc", GetType(String))) For i = 0 To (id.Length - 1) dr = dt.NewRow dr("ID") = id(i) dr("Desc") = desc(i) dt.Rows.Add(dr) Next RadGrid1.DataSource = dt RadGrid1.DataBind()


column "ID" has values in it, e.g. 1, 2, 3, etc., and I want the grid column to show hyperlinks, e.g. "order.aspx?id=1", "order.aspx?id=2", "order.aspx?id=3", etc. How do I do that. I have to use arrays.

2 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 04 May 2008, 04:50 PM
Anna, to have hyperlinks you have to add GridHyperLinkColumns to your grid and define the url for the links in them as in this online demo (see the hyperlink column definition in the source code). Also think about switching to NeedDataSource binding as this will simplify your code:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/SimpleBinding/DefaultCS.aspx

Bear in mind that operations like grouping, filtering, etc. require this type of binding  or data source controls usage.

Kiara



0
Shinu
Top achievements
Rank 2
answered on 05 May 2008, 04:21 AM
Hi Anna,

Try setting the HyperLinkColumn in the aspx as shown below.

ASPX:
<MasterTableView > 
                <Columns> 
                     
                    <telerik:GridHyperLinkColumn  
                        DataNavigateUrlFields="ProductName" UniqueName="ProductName"  
                        HeaderText="ProductName" DataTextField="ProductName"
                    </telerik:GridHyperLinkColumn> 
                     
                </Columns> 
            </MasterTableView> 
             


Shinu.
Tags
Grid
Asked by
anna
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or