Gridview Edit Bootstrap模态对话框仅填充第一行

时间:2013-08-08 19:43:41

标签: jquery gridview modal-dialog

我有一个带有模板列的gridview for edit按钮,它会打开一个bootstrap模式对话框,其中填充的数据没有回发。

这是Gridview:

<asp:GridView ID="gvLocAddresses" runat="server" CssClass="table table-bordered table-striped table-condensed"
                GridLines="None"  AllowSorting="false" PageSize="25" AutoGenerateColumns="false" >
        <Columns>
            <asp:TemplateField HeaderText="Edit" >
                <ItemTemplate>
                    <a id="editLocAddress" href="#dlgLocAddress"  data-toggle="modal" role="button" onclick="EditLocAddress();"  
                        data-id="<%# DataBinder.Eval (Container.DataItem, "Id") %>" 
                        data-IsPrimary = "<%# DataBinder.Eval(Container.DataItem, "IsPrimary") %>"
                        data-Address1 = "<%# DataBinder.Eval(Container.DataItem, "Address1") %>"
                        data-Address2 = "<%# DataBinder.Eval(Container.DataItem, "Address2") %>"
                        data-City = "<%# DataBinder.Eval(Container.DataItem, "City") %>"

                        ><i class="icon-edit"></i></a>
                </ItemTemplate>                        
            </asp:TemplateField> 

这是模态对话框:

<div id="dlgLocAddress" class="modal hide fade" tabindex="-1" role="dialog" 
aria-hidden="true" style="width: 475px;">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        ×</button>
    <h3 id="dlgAddLocAddrLBL">Add Address</h3>
</div>
<div class="modal-body">
    <div class="row">
        <div class="span2 text-right">
            <label for="txtAddrLine1">Address Line1</label>
        </div>
        <div class="span3">
            <input id="txtAddrLine1" type="text" class="text ui-widget-content ui-corner-all" /> 
        </div>
    </div>

     <div class="row">
        <div class="span2 text-right">
            <label for="txtAddrLine2">Address Line2</label>
        </div>
        <div class="span3">
            <input id="txtAddrLine2" type="text" class="text ui-widget-content ui-corner-all" /> 
        </div>
    </div>

    <div class="row">
        <div class="span2 text-right">
            <label for="txtCity">City</label>
        </div>
        <div class="span3">
            <input id="txtCity" type="text" class="text ui-widget-content ui-corner-all" />    
        </div>
    </div>

Heres my Jquery功能:

 function EditLocAddress() {
       var $editLAddr = $('#editLocAddress'),
            addressid = $editLAddr.data('id'),


       $(".modal-body #txtAddrLine1").val($editLAddr.data('address1'));
       $(".modal-body #txtAddrLine2").val($editLAddr.data('address2'));
       $(".modal-body #txtCity").val($editLAddr.data('city'));

   }

现在,当我单击“编辑”时,对话框按钮始终填充第一行。我是Jquery和客户端编程的新手。有人可以请帮助。

谢谢, 斯

0 个答案:

没有答案