首页 新闻 会员 周边 捐助

Repeater下的DropDownList用ajax联动后,怎么取下级DropDownList的值?

0
悬赏园豆:50 [已解决问题] 解决于 2014-05-23 17:42

如题,摘抄代码如下:

<asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound">
                <ItemTemplate>
                        <tr class="tr1" onmouseover="javascript:changebg(this,0)" onmouseout="javascript:changebg(this,1)">
<td align='center' valign='middle'>
    <asp:DropDownList CssClass="des" runat="server" ID="ddlDes"/>
</td>
<td align='center' valign='middle'>
    <asp:DropDownList runat="server" ID="ddlMaterial">
    </asp:DropDownList>
</td>
                        </tr>
                     </ItemTemplate>
                    </asp:Repeater>

 

<script type="text/javascript">
        $(function() {
            $(".des").change(function () {
                var children = $(this).parent().next().find("select");
                children.empty().append($("<option value='-1'>-请选择-</option>"));
                if ($(this).val() != '-1') {
                    $.get("../handler/StoreHandler.ashx", { type: "Material", id: $(this).val() }, function (data) {
                        var objs = eval("(" + data + ")");
                        if (objs.length > 0) {
                            for (var i = 0; i < objs.length; i++) {
                                var result = $("<option></option>");
                                result.val(objs[i].ID);
                                result.text(objs[i].Name);
                                children.append(result);
                            }
                        }
                    });
                }
            });
        })
    </script>

后台处理:

foreach (RepeaterItem item in Repeater2.Items)
            {
                DropDownList ddlDes = item.FindControl("ddlDes") as DropDownList;
                if (ddlDes == null) continue;

                DropDownList ddlMaterial = item.FindControl("ddlMaterial") as DropDownList;
                if (ddlMaterial == null) continue;

                var m = new TModel_NoStandardADModel();
                m.DesId = int.Parse(ddlDes.Text);

               //m.MaterialId=??

           }

问题补充:

用Request.Form["Repeater2$ctl00$ddlMaterial"]这种方式也取不到值

X库恩的主页 X库恩 | 初学一级 | 园豆:159
提问于:2014-05-23 17:16
< >
分享
最佳答案
0

添加隐藏域,用隐藏域中转下拉框的值

X库恩 | 初学一级 |园豆:159 | 2014-05-23 17:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册