Problem: "Does not exist in current context"

J

Jeff

hey

asp.net 2.0 (C'#)

In the code behind file I have this method:
public String AddBR(Object param) {
String text = (String) param;
return text;
}

(( I know this method does nothing, but when I've fixed the compile error
then I will add more code to this method ))

Here I'm using this AddBR method to set the text property of a TextBox:
Text='<%# AddBR(eval(question)) %>'

ERROR:
When I build my website I get this error:
"The name 'eval' does not exist in the current context"

What am I doing wrong here?

Jeff
 
V

Vadivel Kumar

I dont understand why you're using eval here. Since, question is a
variable you can directly pass it on as a parameter. It should work.

Let me know, if i understood the problem wrongly.
 
Joined
Aug 29, 2006
Messages
8
Reaction score
0
DataBinder.Eval

You don't say what the "question" value is.

I am assuming it is a field from a dataview. If that is the case, the following code should be used:

Code:
Text='<%# AddBR((string)DataBinder.Eval(Container.DataItem, "Question")) %>'

Where Container.DataItem is the data from the current row of the dataview and "Question" is the field within the dataview that you wish to pass into the AddBr() method.

I hope that helps.

Gary Francis
Software Developer
http://www.ssil.co.uk
 
J

Jeff

Sorry I forgot 2 " (added " arround the question)
Text='<%# AddBR(eval("question")) %>'
I also tried this:
Text='<%# AddBR(Bind("question")) %>'
but result in this error: The name 'Bindl' does not exist in the current
context"

This code does not work, it just sends the string "question" to the AddBR
method
Text='<%# AddBR("question") %>'
(I thought this was using the AddBR method directly)

I have not solved this problem yet!

Any suggestions?

The "question" represent a column in the resultset. So I'm interested in
sending this value to the AddBR method. Lets say this "question" column has
the value "How do you do?".. Then I want this "How do you do?" to be sent
into the AddBR method.

the purpose of this AddBR method is that I want to replace linefeeds in the
string with <br/> - text formating
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top