Error using Eval in asp.net

Posted by Vuyiswamb under ASP.NET on 11/14/2011 | Points: 10 | Views : 1734 | Status : [Member] [MVP] [Administrator] | Replies : 1
Good Day all

i have the following

   <%# clsFlow.CleanBondNumber(Eval("ATB_NUMBER"))%>


and the Function CleanBondNumber is defined like this


Public Shared Function CleanBondNumber(ByVal val As Object) As String


Dim Final_bond_acc_no As String = String.Empty

If (val.ToString().Contains("Offer")) Then

'Get rid of the Offer string
Dim Finalstring As String

Finalstring = val.ToString.Substring(6)

If (Finalstring.Contains(" ")) Then

'Get the Position of the Space
Dim SpacePost As Integer
SpacePost = Finalstring.IndexOf(" ")

Final_bond_acc_no = Finalstring.Substring(0, SpacePost - 1)

Return Final_bond_acc_no

Else
Return val.ToString()
End If

Else

If (val.Contains(" ")) Then

'Get the Position of the Space
Dim SpacePost As Integer
SpacePost = val.IndexOf(" ")

Final_bond_acc_no = val.Substring(0, SpacePost - 1)
Return Final_bond_acc_no
Else
Return val.ToString()
End If
End If

End Function


i stepped through the code and after it returns something i cant bind the Data, i get an Exception


	 <%# clsFlow.CleanBondNumber(Eval("ATB_NUMBER"))%>	'=' expected.	


Thanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: SheoNarayan on: 11/14/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Is it inside any Data controls like GridView or Repeater or directly on the page. If it is directly on the page whatever you have written is fine otherwise you have to write something like below

<%= clsFlow.CleanBondNumber(Eval("ATB_NUMBER"))%>

Replace # with =. # is used inside the Data controls only and = is used to write the value of the variable.

Thanks



Regards,
Sheo Narayan
http://www.dotnetfunda.com

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response