Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because you are trying to access an HTML element on the server side as a server side control. You could make your <code>select</code> element into a server side control by simply adding <code>runat="server"</code> to it like such:</p> <pre><code>&lt;select id="ExTypeDD" runat="server" class="Nbr1" style="width:90px"&gt; </code></pre> <p>But after that you would still have the issue that this control, although accessible on the server side now, it does not have the id of ExTypeDD because it is dynamically created in the ItemTemplate of your ListView which generates a unique ID value for each newly created control . You can verify this by viewing source on the page rendered in the browser and checking the ID value on the select element.</p> <p>To do what you're trying to do on the server side you would need to do something along the lines of this:</p> <p>Add an onItemCreated event handler to your ListView:</p> <pre><code>&lt;asp:ListView runat="server" id="ListView1" onItemCreated="ListView1ItemCreated"&gt; </code></pre> <p>Replace this:</p> <pre><code>&lt;input type="button" id="btn_update" class="Updt" value="Update" /&gt; </code></pre> <p>With this:</p> <pre><code>&lt;asp:button id="btn_update" text="Update" runat="server" /&gt; </code></pre> <p>Add the event handler to the code behind:</p> <pre><code>protected void ListView1ItemCreated(object sender, ListViewItemEventArgs e){ var myselect = (HtmlSelect)e.Item.FindControl("ExTypeDD"); var mybutton = (Button)e.Item.FindControl("btn_update"); mybutton.OnSubmit += (o,e) =&gt; { // do something with myselect selected value var selectedvalue = myselect.Value; }; } </code></pre> <p><strong>NOTE: the above code is not tested and probably won't compile, you will need to make necessary corrections, but it should give you the idea for a way to solve your problem. Hope it helps.</strong></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