Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom template databound control won't generate content

Status
Not open for further replies.

DixieFlatline

Programmer
Aug 2, 2000
57
CA
Hi,

Using the example provide by Microsoft, I created a a databound template control that iterates through a custom collection. When I test this control using an aspx, I can see the the control is iterating. I can see the format I put into the template being generated i times for i equals the size of the collection. But when I try to access the dataitem, nothing gets printed...

<mypackage:mycontrol .... >
<mytemplate>
<b> <%# Container.DataItem.MyString%> </b>
</mytemplate>
</mypackage:mycontrol>

I can see that <b> </b> showing up 8 times on the generated html page. But MyString is no where to be found! I tried just printing it out as I have done above, setting it to a label.... nothing works. I check the code and I did remember to set DataItem for each iteration and I did remember to add each Item to the Control collection... what am I doing wrong!! Has anyone successfully build a databound control? any help would be greatly apprietiated. I am sure I am just forgetting something silly!

Dix



 
My first thought is that if you are using C# the syntax for the data is different (at least I could never get anything but this style to work).

<%# DataBinder.Eval(Container, &quot;DataItem.vacation&quot;) %>

Failing that have you tried
<%# Container.DataItem(&quot;MyString&quot;) %>

I have not done a tonne of this as none of my custom controls iterate through any data. Yet;-)

Good luck and if you find a solution I know I would not mind hearing it.
Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top