Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Getting the value of another cell in Grid in ItemTemplate

Reply
Thread Tools

Getting the value of another cell in Grid in ItemTemplate

 
 
msnews.microsoft.com
Guest
Posts: n/a
 
      08-09-2004
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


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      08-11-2004
Hi James,

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

Ken


"msnews.microsoft.com" <~(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another topic about getting data from ItemTemplate in DataGrid Isoaxis@gmail.com ASP .Net 1 10-03-2005 04:07 PM
can code inside a Repeater's ItemTemplate modify controls in the ItemTemplate? Bennett Haselton ASP .Net 1 09-24-2004 01:59 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net 1 08-11-2004 12:42 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net Web Controls 1 08-11-2004 12:42 AM
Getting the value from ItemTemplate of DataList Vannela ASP .Net 1 12-12-2003 02:57 PM



Advertisments