Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get result of #Eval("X") in my C# code?

Tags:

c#

asp.net

I have some asp code with an asp:Repeater object.

I am familiar with using <%# Eval("field") to print dataitem.field to the HTML code. However, what can I do if I want to get the result of Eval("field") saved to a string literal for further processing?

Update: I feel like I owe an apology for not being more specific. As the first answerer suggetss, I am planning to use the result in an ItemTemplate. However, what about field of the current record that are not strings? What if I have some complex type that contains all sorts of weird ** and I want to refer to the fields in my item template, and not as strings?

like image 284
Vivian River Avatar asked Dec 18 '25 01:12

Vivian River


1 Answers

I'm not sure if this is what you're asking for, but if you want to do an Eval in a context outside of .aspx markup, you can use the DataBinder.Eval method directly in your code.

like image 164
Jacob Avatar answered Dec 19 '25 14:12

Jacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!