0

this is definitely an easy question but I still don't know what exactly it is for. Can anybody tell me what ImageUrl='<%# Eval("FileName") %>' means? I still don't get the idea why we need to include %#.

2
  • 3
    You shouldn't say "sorry", we all here for learning. Commented Dec 15, 2012 at 9:28
  • It's a database fieldname from which the URL (or source of image) will be set. Commented Dec 15, 2012 at 9:38

4 Answers 4

2

<%# Eval("FileName") %> is used in the context of binding data from a collection to a control. Probably the value for the imageurl is coming from a property of an object in the collection

For example, List<Photo> where Photo has a property of FileName. If you are binding that to a gridview, a repeater, etc, you'll access that property for each item in the collection when binding to such controls

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much everybody. Now I understand everything about this.
2

in this Line...

ImageUrl='<%# Eval("FileName") %>'

ImageURL the attribute of your asp:ImageButton control that is used to specify the Url of the Image File to be Used

Code between '<% and %>' tags are writtent to be Executed on the Server

'#' is used to specify that the result of server side execution will be bound hear

Eval KeyWord is Used To Evaluate the perticular Column Value (that you specify ("--hear--")) from The DataSourse

Comments

1

When you are using a Template Control like Repeater , GridView , etc. you are actually iterating in a list of data records, and <%# Eval("FileName") %> here means give me the value of the column named FileName.

Comments

1

Here we have used the Eval function which is used for one way databinding. FileName is the field name you are associating. Anything that's written inside <%# %> is parsed by asp.net engine before generating the webpage source which is pure client side script and html tags. So Eval function is executed at server end by ASP.net engine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.