1

我有一个带有用于编辑按钮的模板列的 gridview,它打开一个引导模式对话框,其中填充了没有回发的数据。

这是 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>

这是我的 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 和客户端编程的新手。有人可以帮忙吗。

谢谢, 斯里

4

0 回答 0