
Karl Wilkens
Top achievements
Rank 1
Karl Wilkens
asked on 05 Jan 2011, 10:17 PM
Hi,
We have data coming in where we want to find columns that contain keywords such as 'Upload' but the full column name could contain other words. Once we find that column, we want to change the text of each cell to a link - either by just injecting a hand built a href string, or alternately, adding in a hyperlink.
Is this even possible. Virtually all examples assume the grid column and data column are known - in this case we dont know the names exactly.
Thanks!
We have data coming in where we want to find columns that contain keywords such as 'Upload' but the full column name could contain other words. Once we find that column, we want to change the text of each cell to a link - either by just injecting a hand built a href string, or alternately, adding in a hyperlink.
Is this even possible. Virtually all examples assume the grid column and data column are known - in this case we dont know the names exactly.
Thanks!
4 Answers, 1 is accepted
0
Hello Karl,
You could try the following approach:
I hope this helps.
Best regards,
Daniel
the Telerik team
You could try the following approach:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
foreach
(GridColumn col
in
RadGrid1.MasterTableView.Columns)
{
if
(col.UniqueName.Contains(
"Upload"
))
(e.Item
as
GridDataItem)[col].Text ...
}
}
}
I hope this helps.
Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Karl Wilkens
Top achievements
Rank 1
answered on 06 Jan 2011, 09:50 AM
Hi and thanks. We tried your suggestion. The for Next loop never executes, as if there are no columns in RadGrid1.MasterTableView.Columns. Any thoughts on what we are doing wrong? This is in ItemDataBound and I stripped out everything else to get the the essential code.
Dim dataitem As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Dim col As Telerik.Web.UI.GridColumn
For Each col In RadGrid1.MasterTableView.Columns
If col.UniqueName.ToLower.Contains("upload") Then
dataitem(col).Text = "Test"
End If
Next
Dim dataitem As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Dim col As Telerik.Web.UI.GridColumn
For Each col In RadGrid1.MasterTableView.Columns
If col.UniqueName.ToLower.Contains("upload") Then
dataitem(col).Text = "Test"
End If
Next
0

Princy
Top achievements
Rank 2
answered on 06 Jan 2011, 10:11 AM
Hello Karl,
I guess your RadGrid have AutoGeneratedColumns. If that the case you can try the following code snippet to loop through each column in grid.
C#:
Thanks,
Princy.
I guess your RadGrid have AutoGeneratedColumns. If that the case you can try the following code snippet to loop through each column in grid.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
foreach
(GridColumn col
in
RadGrid1.MasterTableView.AutoGeneratedColumns)
{
. . . . .
}
}
}
Thanks,
Princy.
0

Karl Wilkens
Top achievements
Rank 1
answered on 06 Jan 2011, 11:04 AM
Thanks! That was the issue.
I now have a working solution!
I now have a working solution!