<asp:DataGrid id='DataGrid1' AutoGenerateColumns='False' runat='server'>
<Columns>
<asp:TemplateColumn HeaderText='Link'>
<ItemTemplate>
<asp:HyperLink Runat =server NavigateUrl =’<%#GetURL(DataBinder.Eval(Container.DataItem, 'RegionDescription').ToString())%>’ ID='Hyperlink1'>
<%#DataBinder.Eval(Container.DataItem, 'RegionDescription')%>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
VB.NET
Protected Function GetURL(ByVal fldval As String) As String
If fldval.IndexOf('http://', 0, fldval.Length) = 0 Then
Return fldval
Else
Return 'http://' + fldval
End If
End Function ’GetURL
C#
protected string GetURL (string fldval )
{
if (fldval.IndexOf ( 'http://' , 0, fldval.Length ) ==0)
{
return fldval;
}
else
{
return 'http://' + fldval;
}
}
Share with