Getting the value of another cell in Grid in ItemTemplate

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

Here's a tough one, but one I've run into serveral times now.

I know that you can use DataBinder.Eval(Container, "Field") to set a value
of a control in an item template. Works great.

However I need to do some inline code, because some of the items I need to
display one set of controls, and some of the items I need to display another
set of controls based on the value in the record.

So I tried to do this:

<%if (DataBindiner.Eval(Container, "Field").ToString() == string.Empty) {%>
HTML controls
<%} else {%>
Some other HTML Controls
<%}%>

What I get is an error that container doesn't exist.

Does anyone know how I can get the value of a field and then have the above
if work correctly?

I tried setting it to a label's text property (that works fine) and then
testing the label's text property in the if, but of course that doesn't
work, because it doesn't know that control because it's part of the
ItemTemplate.

Thanks!
James Hancock
 
K

Ken Cox [Microsoft MVP]

Hi James,

Just checking that it isn't just a typo? See the spelling of DataBindiner

Ken
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top