Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way is to implement the <code>OnDataBinding</code> event for the user control. I try to stay away from putting code inline in the aspx using webforms if possible.</p> <p>When the repeater gets bound, for each item that is bound, the <code>OnDataBinding</code> will fire for your user control and your handler can do what it needs. You don't have to go searching for the controls.</p> <p>Here is an example:</p> <pre><code>// in your aspx &lt;uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" OnDataBinding="pfd1_DataBinding" /&gt; // in your codebehind implement the OnDataBinding event protected void pfd1_DataBinding(object sender, System.EventArgs e) { pfd uc = (pfd)(sender); uc.ContainerID = _containerID.ToString(); uc.ParentItemID = Eval("ItemID"); // Here you can do more like access other items like hidden fields // or cached objects or even other controls etc... Skys the limit. } </code></pre> <p><strong>EDIT:</strong> Notice from your comment you require more data than what is found in the datasource. In this case what I usually do is just make private member variables in the .cs that I store data in. So when you have the container ID just store it in a variable that will be accessible.</p> <p>Eg in your .cs for your page:</p> <pre><code>public partial class _TestPage : System.Web.UI.Page { private int _containerID { get; set; } </code></pre> <p>Then when you load the data just set the <code>_containerID</code> property and it will be accessible in the <code>OnDataBinding</code> event. Just make sure you are binding after you have set the <code>_containerID</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload