Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you'd be better off using the built in support for IDs inside a Repeater. If the goal is to assign it an ID to make it easy to find the proper control after the data has been bound you might try something like this:</p> <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="QuestionID" Visible="False" Runat="server"&gt;&lt;%#DataBinder.Eval(Container.DataItem, "FieldContent")%&gt;&lt;/asp:Label&gt; &lt;asp:DropDownList ID="MyDropDownList" Runat="server"&gt;&lt;/asp:DropDownList&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Then, in your code you can loop through the items in the Repeater until you find the label you're looking for:</p> <pre><code>foreach (RepeaterItem curItem in Repeater1.Items) { // Due to the way a Repeater works, these two controls are linked together. The questionID // label that is found is in the same RepeaterItem as the DropDownList (and any other controls // you might find using curRow.FindControl) var questionID = curRow.FindControl("QuestionID") as Label; var myDropDownList = curRow.FindControl("MyDropDownList") as DropDownList; } </code></pre> <p>A Repeater basically consists of a collection of RepeaterItems. The RepeaterItems are specified using the ItemTemplate tag. Each RepeaterItem has its own set of controls that are, by the very nature of a Repeater, associated with each other.</p> <p>Say you're pulling the Repeater data from a database. Each Repeater item represents data from an individual row in the query results. So if you assign the QuestionID to a label and the QuestionName to a DropDownList, the ID in the label would match up with the name in drop down.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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