DataBinder question

  • Thread starter Thread starter Kevin Blount
  • Start date Start date
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"?
 
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
 
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
 
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
 
Back
Top