DataBinder question

K

Kevin Blount

In a DataList, I'm using the following:

<%# DataBinder.Eval(Container.DataItem, "characterization")%>

I was wondering if it's possible to create a string that would contain
the value of the above line, so that I can manipulate it:

I tried

string resultText = DataBinder.Eval(Container.DataItem, "characterization");

....but I get an error saying "Container" does not exist in the current
context.

Any advise on how to get the value of "characterization" into "resultText"?
 
G

Guest

An easy way to manipulate it is to pass it to a function. You could put a
function in the code behind :
public string DoStringWord(string characterization){
return characterization; //Do something here
}

and in the page put:
<%# DoStringWord(DataBinder.Eval(Container.DataItem, "characterization")) %>


Give it a go.

Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com
 
K

Kevin Blount

Hi Ciaran,

I gave that a try, but had to make a small modification. The method
(DoStringWord) was expecting a string. Once I figured that out, and
added .ToString() at the end of the call, your script worked wonderfully!

<%# DoStringWord(DataBinder.Eval(Container.DataItem,
"characterization").ToString()) %>

Thanks for the reply and the answer :)

Kevin
 
K

Kevin Blount

Hi Ciaran,

I gave that a try, but had to make a small modification. The method
(DoStringWord) was expecting a string. Once I figured that out, and
added .ToString() at the end of the call, your script worked wonderfully!

<%# DoStringWord(DataBinder.Eval(Container.DataItem,
"characterization").ToString()) %>

Thanks for the reply and the answer :)

Kevin
 

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,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top