Live Chat Icon For mobile
Live Chat Icon

How can I display the field as a link in the DataGrid? If may or may not be stored in the ‘http://’ format.

Platform: ASP.NET| Category: DataGrid

<asp:DataGrid id='DataGrid1' AutoGenerateColumns='False' runat='server'>
	<asp:TemplateColumn HeaderText='Link'>
			<asp:HyperLink Runat =server NavigateUrl =’<%#GetURL(DataBinder.Eval(Container.DataItem, 'RegionDescription').ToString())%>’ ID='Hyperlink1'>
				<%#DataBinder.Eval(Container.DataItem, 'RegionDescription')%>


Protected Function GetURL(ByVal fldval As String) As String
	If fldval.IndexOf('http://', 0, fldval.Length) = 0 Then
	            Return fldval
	            Return 'http://' + fldval
	End If
End Function ’GetURL


protected	string GetURL (string fldval   )  
	if  (fldval.IndexOf ( 'http://' , 0, fldval.Length ) ==0)
		return fldval;
		return 'http://' + fldval;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.