asp.net - get selected value from dropdownlist with jquery dialog -


i'm new jquery dialog in asp.net. i'm trying selected value dropdownlist open in jquery dialog. first user click button , dialog show up. in dialog, user select item in dropdownlist , when user click ok, update query execute based on selected value dropdownlist. problem is, there no change in table when user click ok. code have. in advance

<script type="text/javascript">     function showpopup(message) {         $(function () {             $("#dialog").dialog({                 modal: true,                 buttons: {                     ok: function () {                         $("[id*=btnokstatus]").click();                     },                     close: function () {                         $(this).dialog('close');                     }                 }             });         });     }; </script>  xml    <asp:imagebutton id="btnupdatestatus" runat="server"     imageurl="~/images/btnupdatestatus.png" height="40px" width="50px"      style="vertical-align: middle;" borderstyle="none" onclick="btnshowpopup_click" />``   <div id="dialog" style="display: none"> <asp:label id="lbldialog" runat="server" text="sila pilih status: "></asp:label><br /><asp:dropdownlist     id="ddlstatus" runat="server">     <asp:listitem>new</asp:listitem>     <asp:listitem>pending</asp:listitem>     <asp:listitem>complete</asp:listitem>    </asp:dropdownlist>     </div>        <asp:button id="btnokstatus" runat="server" text="button" style =                               "display:none" onclick = "btnokstatus_click" /> 

vb

protected sub btnshowpopup_click(sender object, e system.eventargs) handles btnupdatestatus.click     dim message string = ""     clientscript.registerstartupscript(me.gettype(), "popup", "showpopup('" + message + "');", true) end sub  protected sub btnokstatus_click(sender object, e eventargs)     using mysqlconnection = new mysqlconnection(connstr)         mysqlconnection.open()          querystr = "update `order` set status=@status id=@orderid"         cmd = new mysqlcommand(querystr, mysqlconnection)         cmd.parameters.addwithvalue("@orderid", page.request.querystring("orderid").tostring())         cmd.parameters.addwithvalue("@status", ddlstatus.selectedvalue)         dim num integer = cmd.executenonquery()          if num > 0             clientscript.registerstartupscript(page.[gettype](), "key", "alert('success!')", true)         else             clientscript.registerstartupscript(page.[gettype](), "key", "alert('fail')", true)         end if         mysqlconnection.close()     end using end sub 

the following selector return selected value.

$('#ddlstatus > li:selected').val() 

this appears more of asp.net question, however. if want selected value of dropdownlist in vb.net code, can use id dropdownlist , access dropdownlist in vb.net code,

ddlstatus.selectedvalue 

try changing this

protected sub btnokstatus_click(sender object, e eventargs)     using mysqlconnection = new mysqlconnection(connstr)         mysqlconnection.open()          querystr = "update `order` set status=@status id=@orderid"         cmd = new mysqlcommand(querystr, mysqlconnection)         cmd.parameters.addwithvalue("@orderid", page.request.querystring("orderid").tostring())         cmd.parameters.addwithvalue("@status", ddlstatus.selectedvalue)         dim num integer = cmd.executenonquery()          if num > 0             clientscript.registerstartupscript(page.[gettype](), "key", "alert('success!')", true)         else             clientscript.registerstartupscript(page.[gettype](), "key", "alert('fail')", true)         end if         mysqlconnection.close()     end using end sub 

to this:

protected sub btnokstatus_click(sender object, e eventargs)     if page.ispostback = false     using mysqlconnection = new mysqlconnection(connstr)         mysqlconnection.open()          querystr = "update `order` set status=@status id=@orderid"         cmd = new mysqlcommand(querystr, mysqlconnection)         cmd.parameters.addwithvalue("@orderid", page.request.querystring("orderid").tostring())         cmd.parameters.addwithvalue("@status", ddlstatus.selectedvalue)         dim num integer = cmd.executenonquery()          if num > 0             clientscript.registerstartupscript(page.[gettype](), "key", "alert('success!')", true)         else             clientscript.registerstartupscript(page.[gettype](), "key", "alert('fail')", true)         end if         mysqlconnection.close()     end using     end if end sub 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -