binding value in hiddenfield using Eval

2k Views Asked by At

I am using this code in my website, where it gives me the parser error, "The server tag is not well formed."

<asp:HiddenField runat="server" ID="hfFirstName" Value='<%# String.IsNullOrEmpty(Eval("Title").ToString()) ? Eval("FirstName") : (Eval("Title").ToString().Split(' ')[0]) %>' />

please help me in this.

1

There are 1 best solutions below

0
On BEST ANSWER

Instead of using .Split(' ') try using .Split(" ".ToCharArray()).

That should get rid of the parser error you're seeing.