Wednesday, December 01, 2004

ASP.NET, Datagrid, Textbox, Formatting

Link

I used the above link & created a single formatting function which replaced certain characters (such as vbcrlf) with their HTML equivilents. This was placed in a standard module.

Function ConvertToHTML(ByVal arg As Object) As String
Dim strTemp As String
strTemp = Replace(arg, vbCrLf, "BR")
Return strTemp
End Function


The databinding for the label control (the control which displays the data rather than editing it) was then modified from:
DataBinder.Eval(Container, "DataItem.TaskComments") to ConvertToHTML(DataBinder.Eval(Container, "DataItem.TaskComments"))

The aspx page cannot read a module function, producing the error 'Function not declared'. The solution to this was to create a wrapper function in the code behind page.

Public Function ConvertToHTML(ByVal arg As Object) As String
Return modFunctions.ConvertToHTML(arg)
End Function

No comments: