Let’s say a control X has a template called RowTemplate.
So X’s markup would be like:
<foo:X>
<RowTemplate>
<foo:Y>...</foo:Y>
</RowTemplate>
</foo:X>
My question is: How can the Y control be sensitive to the data context? I know I can use template inline tags to get access to the data context: <%# Eval("Id") %>, but I cannot pass this information to Y because template inline tags are not allowed in server controls.
So I don’t know how I could use the Object’s Id (Eval(“Id”)) in Y.
By adding a handler to the ItemDataBound event (or some other similar event on your foo:X control), you can access controls in your row template. My example code is from a DataList, so your event handlers will probably be different.
In the code behind – wire up the event handler:
Then in the event handler, access the controls in your row. Your data might not be a DataRow, so change that as needed.