如何在客户端打开和取消EditItemTemplate

时间:2016-09-21 11:21:55

标签: javascript c# jquery asp.net ajax

如何通过javascript在编辑模式下打开和取消列表视图行? 我使用服务器方法打开行,但每次都必须再次绑定列表视图。

我想找到这些行的等效javascript方法:

ListFamilyRelation.EditIndex = e.NewEditIndex;//EDIT

ListFamilyRelation.EditIndex = -1;//CANCEL

服务器方法:

protected void ListFamilyRelation_ItemEditing(object sender, ListViewEditEventArgs e)
            {
                ListFamilyRelation.EditIndex = e.NewEditIndex;
                FamilyRelationRepository familyrepationRepo = new FamilyRelationRepository();

                List<FAMILYRELATION> familyrelationList = familyrepationRepo.All.ToList();
                ListFamilyRelation.DataSource = familyrelationList;
                ListFamilyRelation.DataBind();
            }

我的模板:

          <ItemTemplate>

                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-4 code">
                            <%#:Item.RELATION_CODE%>
                        </div>
                        <div class="col-lg-4 name">
                            <%#:Item.RELATION_NAME%>
                        </div>
                        <div class="col-lg-4">

                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit"  CssClass="btn btn-primary btn-md white_cr"  >Edit</asp:LinkButton>


                        </div>
                    </div>
                </div>

            </ItemTemplate>



            <AlternatingItemTemplate>

                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-4 code">
                            <%#:Item.RELATION_CODE%>
                        </div>
                        <div class="col-lg-4 name">
                            <%#:Item.RELATION_NAME%>
                        </div>
                        <div class="col-lg-4">
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit" CssClass="btn btn-primary btn-md white_cr"  >Edit</asp:LinkButton>

                        </div>
                    </div>
                </div>

            </AlternatingItemTemplate>

            <InsertItemTemplate>
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-4 code">
                        </div>
                        <div class="col-lg-4 name">

                        </div>
                        <div class="col-lg-4">
                            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />


                        </div>
                    </div>
                </div>



            </InsertItemTemplate>

            <EditItemTemplate>
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-4 code">
                            <asp:Label ID="lblUpCode" runat="server" Text='<%#Eval("RELATION_CODE") %>'></asp:Label>
                        </div>
                        <div class="col-lg-4 name">
                            <asp:TextBox ID="txtUpRelation" runat="server" Text='<%#Eval("RELATION_NAME") %>' Width="100px"></asp:TextBox>
                        </div>
                        <div class="col-lg-4">
                            <asp:LinkButton ID="lnkUpdate" runat="server" CommandName="Update">Update1</asp:LinkButton>
                            <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                            <asp:LinkButton ID="lnkCancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton>

                        </div>
                    </div>
                </div>

            </EditItemTemplate>

0 个答案:

没有答案