Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure that if it is your business requirement or what but my suggestion is not to remove the entry from drop down. Lets say in Row 1 user selected value 1, so Value 1 is removed from other drop downs in remaining rows, in Row 2 user selects value 2, which is also removed for the remaining ones. Now in row 1 user selects value 3, now you will have to remove the value 3 from remaining dropdowns and also add value 1 back in them.</p> <p>My suggestion is to call a javascript method and hold your selected values in javascript, if user selects a value that is already selected, simply give him an alert that you have already selected this value. Through this approach you can reduce the server side postbacks as well, if you are doing postback only to remove the values.<br> so your solution should be like:</p> <pre><code>&lt;asp:Repeater ID="rptTableMapper" runat="server" DataSourceID="dsSQLColumnNames" OnItemDataBound="rptTableMapper_ItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;table width="500px"&gt; &lt;tr&gt; &lt;td&gt; &lt;dx:ASPxComboBox ID="cmbCsvColumns" onchange="cmbCsvColumns_SelectedIndexChanged(this);" runat="server" AutoPostBack="False"&gt; &lt;/dx:ASPxComboBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>and your javascript should be like:</p> <pre><code>var selectedValues = ""; function cmbCsvColumns_SelectedIndexChanged(obj) { if(selectedValues.indexOf(e.options[e.selectedIndex].value + ",") != -1) { alert("Your message"); } else selectedValues = selectedValues + e.options[e.selectedIndex].value + ","; } </code></pre> <p>You have to enhance the javascript method a little bit to avoid issues like matching of "1," in "11,"</p> <p>I have used an asp:dropdown in repeater and on server side you can acheive it like:</p> <pre><code>protected void cmbCsvColumns_SelectedIndexChanged(object sender, EventArgs e) { string s = ((DropDownList)(sender)).ClientID; for (int i = 0; i &lt; rptTableMapper.Items.Count; i++) { DropDownList cmb = (DropDownList)(rptTableMapper.Items[i].FindControl("cmbCsvColumns")); ListItem selectedItem = ((DropDownList)(sender)).SelectedItem; if (cmb.ClientID != s) { foreach (ListItem li in cmb.Items) { if (li.Value == selectedItem.Value) { cmb.Items.Remove(li); break; } } } } } </code></pre> <p>The thing that you have to handle it is that if an item removed from dropdown is unselected than how to add it back in the other drop downs.</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. 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