Gridview无法正常工作编辑命令不会触发

时间:2017-05-14 12:21:10

标签: c# asp.net

当我们点击gridview上的编辑命令有时它会触发,有时不会在页面更改时(转到下一页),有时会转到另一个方法,有时它是未经检查的数据,它绑定在gridview上。 我最近2天烦恼这个问题请任何人有解决方案然后帮助我。 非常感谢

     <div class="panel-body ">
                <div class="table-responsive">
                    <asp:GridView Width="100%" GridLines="None" PagerSettings-Visible="false" ShowHeader="true"
                        runat="server" ID="grdcontrl" AutoGenerateColumns="false" class="table table-bordered table-hover panel-primary table-striped "
                        AlternatingRowStyle-CssClass="tr2" DataKeyNames="ID" OnRowCommand="grdcontrl_RowCommand" HeaderStyle-CssClass="panel-heading" OnRowDeleting="grdcontrl_RowDeleting">
                        <AlternatingRowStyle CssClass="tr2" />
                        <Columns>
                            <asp:TemplateField HeaderText="PID">
                                <ItemTemplate>
                                   <asp:Label ID="lblId" Text='<%# Eval("ID") %> ' runat="server"></asp:Label>
                                   <asp:Label ID="Label1" Text='<%# Eval("ParentsID") %> ' Visible="false" runat="server"></asp:Label>
                                </ItemTemplate>

                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblView" Text='<%# Eval("ControlToDisplay") %>' runat="server"></asp:Label>
                                </ItemTemplate>

                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Address">
                                <ItemTemplate>
                                    <asp:Label ID="LblLabel" Text='<%# Eval("FieldLabel") %>' runat="server"></asp:Label>
                                </ItemTemplate>

                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Gender">
                                <ItemTemplate>
                                   <asp:Label ID="lblChechbx" Text='<%# Eval("ID") %> ' Visible="false" runat="server"></asp:Label>
                                            <asp:CheckBox ID="ckActv" runat="server" Checked='<%# Eval("IsActive") %>' OnCheckedChanged="ckActv_CheckedChanged" AutoPostBack="true" />
                                </ItemTemplate>

                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Date of Birth">
                                <ItemTemplate>
                                     <asp:Label ID="lblOptnVal" Text='<%# Eval("OptionValue") %>' runat="server"></asp:Label>
                                </ItemTemplate>

                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Action">
                                <ItemTemplate>
                                    <asp:ImageButton ID="edit" runat="server" CommandName="editts" CommandArgument='<%# Eval("ID") %>' ImageUrl="../Content/themes/images/user_edit.png" />
                                  <%--  <asp:ImageButton ID="imgEditPatient" runat="server" CommandName="EditDetails" CommandArgument='<%# Eval("ID") %>' ImageUrl="../Content/themes/images/user_edit.png" ToolTip="Edit" />
                                    <asp:ImageButton ID="imgDeletePatient" runat="server" CommandName="DeleteDetails" CommandArgument='<%# Eval("ID") %>' ImageUrl="../Content/themes/images/Delete.png" Height="16px" Width="16px" ToolTip="Delete" OnClientClick="return confirm('Are you sure you want to delete?.');" />
                                   --%>
                                </ItemTemplate>

                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle CssClass="panel-heading" />
                        <PagerSettings Visible="False" PageButtonCount="999999" />
                    </asp:GridView>
                </div>
            </div>

1 个答案:

答案 0 :(得分:0)

在UpdatePanel中使用ScriptManager.RegisterStartupScript Method导航页面

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "navigate", "location.href = 'SomePage.aspx'", true);