0

In a text field in ASP.NET how would I concatenate a string with a variable, method call, or database entry?

For example:

Text="<some string> + MethodCall()"
Text="<some string> + variable"
2
  • Could you show some code of what you have so far? Commented Jun 21, 2012 at 16:38
  • I answered my own question below. I posted in hopes of helping someone else how had the same question and couldn't find the answer. If you have any other solutions that might be better, feel free to post. I'll update my question to better suit what I was look for. Commented Jun 21, 2012 at 16:41

1 Answer 1

1

To concatenate a string with a database entry in a repeater:

Text='<%# "Entry: " +  ((<class name storing database values>)Container.DataItem).Entry%>'>

To concatenate a string with a database entry outside a repeater:

Text='<%# "Entry: " +  <class name storing database values>.<Get Entry Name Method>%>'>

To concatenate a string with a method:

Text='<%# "Entry: " +  <method name>%>'>

The method should return a string.

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

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.