Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would recommend using the DropDownList control to display your individual results.</p> <p>In the front end, you need to simply declare your drop down list as such:</p> <pre><code>&lt;asp:DropDownList id="ddl1" runat="server"&gt; &lt;/asp:DropDownList&gt; </code></pre> <hr> <p>Your backend code should contain a method that binds the datasource to the drop down list. ex:</p> <pre><code>this.ddl1.DataSource = ds; //Assuming that you are using a DataSet called ds. this.ddl1.DataTextField = "TextColumnName"; //The column name or property name you want to use as the text data this.ddl1.DataValueField = "ValueColumnName"; //The column name or property name you want to use as the value data this.ddl1.DataBind(); </code></pre> <p>Call this in the backend only when binding is needed, such as on the initial page load, or when the datasource needs to be refreshed.</p> <p>If you want a repeater of drop down lists, simply do the following:</p> <pre><code>&lt;asp:repeater id="rpt1" runat="server"&gt; &lt;ItemTemplate&gt; &lt;asp:DropDownList id="ddl1" runat="server"&gt; &lt;/asp:DropDownList&gt; &lt;/ItemTemplate&gt; &lt;/asp:repeater&gt; </code></pre> <hr> <p>Bind your datasource that contains the collection of values you would want for each DDL to the repeater and within the repeater's OnItemDatabound event, bind the data item or source to the dropdown list for each repeater item.</p> <p>If you want your choices to persist, wrap the all of the binding logic into a method that's only called on Page_Load inside of an if statement that checks if the page is in PostBack.</p> <pre><code>if(!IsPostBack) { //Add method here } </code></pre> <p>The Viewstate should take care of the rest.</p>
 

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