Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Need to manipulate (Container.DataItem("mydbfield")) inside <itemtemplate> (http://www.velocityreviews.com/forums/t773468-need-to-manipulate-container-dataitem-mydbfield-inside-itemtemplate.html)

Chumley the Walrus 06-07-2004 07:02 PM

Need to manipulate (Container.DataItem("mydbfield")) inside <itemtemplate>
 
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

Scott Mitchell [MVP] 06-08-2004 12:29 AM

Re: Need to manipulate (Container.DataItem("mydbfield")) inside<itemtemplate>
 
Chumley the Walrus wrote:
> 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.Dat aItem("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/Cust...umnValue.shtml

Happy Programming!

--

Scott Mitchell
mitchell@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPMessageboard.com
http://www.ASPFAQs.com

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


All times are GMT. The time now is 11:02 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57