Need to manipulate (Container.DataItem("mydbfield")) inside <itemtemplate>

  • Thread starter Chumley the Walrus
  • Start date
C

Chumley the Walrus

Inside a datalist, or repeater control <itemtemplate>, i'm trying to
do an If statement with objects from my recordset :


<% if (Container.DataItem("mydbfield")) <> "" then
response.write(Container.DataItem("mydbfield2"))
end if %>

...but i get a Container not declared error. It seems i can't
manipulate these "containers" inside <itemtemplates>

???
Chum
 
S

Scott Mitchell [MVP]

Chumley said:
Inside a datalist, or repeater control <itemtemplate>, i'm trying to
do an If statement with objects from my recordset :


<% if (Container.DataItem("mydbfield")) <> "" then
response.write(Container.DataItem("mydbfield2"))
end if %>

..but i get a Container not declared error. It seems i can't
manipulate these "containers" inside <itemtemplates>

Call a "helper function" using the databinding syntax:

<ItemTemplate>
<%# SomeFunctionDefinedInCodeBehindClass(Container.DataItem("field")) %>
</ItemTemplate>

Then, in your code-behind class:

Public Function SomeFunctionDefinedInCodeBehindClass(value as String) as
String
If value <> "" then
Return value
End If
End Function


For an example of using a helper function in a template see:
http://datawebcontrols.com/faqs/CustomizingAppearance/CustomizeColumnValue.shtml

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPMessageboard.com
http://www.ASPFAQs.com

* When you think ASP, think 4GuysFromRolla.com!
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top