大家好, 我有一个asp页面,其中我有一个转发器,在这个转发器中我有86行,每行我有三个下拉列表(钻机,井和驱动程序)。 使用jquery我已填充这些下拉列表。 代码:
Hi guys, I have an asp page, in which i have a repeater where in this repeater i have some 86 rows and each row i have three dropdownlist (rig, well and driver). Using jquery i have populate these dropdownlist. Code:
<td> <asp:DropDownList ID="ddlstatus" CssClass="ddlstatus" runat="server"> <asp:ListItem Value="-1" Text="--Select--" Selected="True"></asp:ListItem> <asp:ListItem Value="1" Text="Active"></asp:ListItem> <asp:ListItem Value="0" Text="InActive"></asp:ListItem> </asp:DropDownList> </td> <td> <asp:DropDownList ID="ddlrig" CssClass="ddlrig myRig" runat="server" Width="100px"> </asp:DropDownList> <asp:HiddenField ID="hdnrig" runat="server" /> </td> <td> <asp:DropDownList ID="ddlwell" runat="server" CssClass="ddlwell myWell" Width="100px"> </asp:DropDownList> <asp:HiddenField ID="hdnwell" runat="server" /> </td> <td> <asp:TextBox ID="txtlocation" CssClass="txtlocation" runat="server" Text='<%# Eval("location")%>'></asp:TextBox> </td> <td> <asp:DropDownList ID="ddldriver" CssClass="ddldriver myDriver" runat="server" Width="100px"> </asp:DropDownList> <asp:HiddenField ID="hdndr" runat="server" /> </td>jquery / Ajax
jquery/Ajax
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "VtWebMethod.aspx/GetWell", data: '{"i":"' + 1 + '"}', dataType: "json", success: function (Result) { //alert(Result.d); Result = Result.d; $(".myRig").append($(Result)); }, error: function (Result) { alert("Error"); } }); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "VtWebMethod.aspx/GetWell", data: '{"i":"' + 2 + '"}', dataType: "json", success: function (Result) { //alert(Result.d); Result = Result.d; $(".myWell").append($(Result)); }, error: function (Result) { alert("Error"); } }); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "VtWebMethod.aspx/GetWell", data: '{"i":"' + 3 + '"}', dataType: "json", success: function (Result) { //alert(Result.d); Result = Result.d; $(".myDriver").append($(Result)); }, error: function (Result) { alert("Error"); } });到目前为止,页面已成功加载,所有下拉列表。 但是当我想在c#或jquery中获取所选值时,在这两个地方它都显示为空/ null。 任何人都可以帮助我。哪里我错了或如何获得下拉列表的选定值。 请帮助我。 谢谢 我的尝试: webmethod
Till now, page is loading successfully, with all dropdownlists. But when i want to get the selected value in c# or in jquery, in both places it is showing empty/null. Can anyone please help me. Where i'm wrong or how to get the selected value of a dropdownlist. Please help me. Thanks What I have tried: webmethod
[WebMethod] public static string GetWell(int i) { string data=""; string send = ""; if (i == 1) { if (MySession.Current.RigDT.Rows.Count > 0) { foreach (DataRow dr in MySession.Current.RigDT.Rows) { data = data + "<option value=" + dr["RigID"].ToString() + ">" + dr["Rig_Name"].ToString() + "</option>"; } send = "<option value=0>--Select--</option>" + data; } } else if (i == 2) { if (MySession.Current.WellDT.Rows.Count > 0) { foreach (DataRow dr in MySession.Current.WellDT.Rows) { data = data + "<option value=" + dr["WellID"].ToString() + ">" + dr["Well_Name"].ToString() + "</option>"; } send = "<option value=0>--Select--</option>" + data; } } else if (i == 3) { if (MySession.Current.DriverDT.Rows.Count > 0) { foreach (DataRow dr in MySession.Current.DriverDT.Rows) { data = data + "<option value=" + dr["RecID"].ToString() + ">" + dr["EmpName"].ToString() + "</option>"; } send = "<option value=0>--Select--</option>" + data; } } return send; }推荐答案
.ajax({ type:POST, contentType:application / json; charset = utf-8, url:VtWebMethod.aspx / GetWell, data:'{i:'+ 1 +'}' , dataType:json, success:function(Result){ //alert(Result.d); Result = Result.d; .ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "VtWebMethod.aspx/GetWell", data: '{"i":"' + 1 + '"}', dataType: "json", success: function (Result) { //alert(Result.d); Result = Result.d;
(。myRig)。append( (".myRig").append(
(Result)); }, error:function(Result){ alert(错误); } }); (Result)); }, error: function (Result) { alert("Error"); } });
更多推荐
使用jquery填充dropdownlist时如何获取dropdownlist选择的值
发布评论