Nested user controls assigning value to childs property.

Z

zb

Scenario:

I have a datalist control bound to a datasource. By itself, this works
just fine. Now, inside the ItemTemplate I have a custom user control (I
wrote this user control) and it has an itemId property exposed so I can
assign this Id based on which it process other info.
How implemented: <uc:processItem id="ucProcess" itemId="32e43432"
runat=server />

Inside the parent repeater control this is what I am doing:
<uc:processItem id="ucProcess" itemId="<%#
DataBinder.Eval(Container.DataItem, "itemId") %>" runat=server />

And, this throws an error that tag is not well formed. What I want to
do is assign my user control's itemid value from the datasource of the
parent datalist. How do I do this?

I rather avoid this solution but I am open to using the ItemDataBound
event handler of the datalist and do the processing here. I tried this
and I could not figure out how to get the container data item. So, if
you have a code that can explain this to me will be very appreciated.

Thanks in advance.
 
Z

zb

Thanks Eliyahu. I feel so stupid, it did the trick. :)



Eliyahu said:
Just replace double quotes with single ones:

itemId='<%# DataBinder.Eval(Container.DataItem, "itemId") %>'

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


zb said:
Scenario:

I have a datalist control bound to a datasource. By itself, this works
just fine. Now, inside the ItemTemplate I have a custom user control (I
wrote this user control) and it has an itemId property exposed so I can
assign this Id based on which it process other info.
How implemented: <uc:processItem id="ucProcess" itemId="32e43432"
runat=server />

Inside the parent repeater control this is what I am doing:
<uc:processItem id="ucProcess" itemId="<%#
DataBinder.Eval(Container.DataItem, "itemId") %>" runat=server />

And, this throws an error that tag is not well formed. What I want to
do is assign my user control's itemid value from the datasource of the
parent datalist. How do I do this?

I rather avoid this solution but I am open to using the ItemDataBound
event handler of the datalist and do the processing here. I tried this
and I could not figure out how to get the container data item. So, if
you have a code that can explain this to me will be very appreciated.

Thanks in advance.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top