0

我有一个使用可折叠扩展器扩展的面板。在我尝试通过代码折叠它之前,它运行良好。

可折叠面板显示在模式弹出窗口中,用户在其中搜索一些数据,这些数据显示在网格中,在网格的每一行中都有一个选择按钮,用于触发我试图关闭的网格的行命令事件控制板。

Markup:
 <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnAdd"
        PopupControlID="pnlpopup" CancelControlID="Cancel" BackgroundCssClass="modalBackground">
    </asp:ModalPopupExtender>
    <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="320px" Width="530px"
        Style="display: none">
        <table width="100%" style="border: Solid 3px #D55500; height: 100%" cellpadding="0"
            cellspacing="0">
            <tr>
                <td>
                    Bridge ID :
                    <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvID" runat="server" ControlToValidate="txtID" ValidationGroup="vldAddBridge"
                        ErrorMessage="Please enter ID" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
                <td>
                    Bridge Name :
                    <asp:TextBox ID="txtBridgeName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBridgeName" runat="server" ControlToValidate="txtBridgeName"
                        ValidationGroup="vldAddBridge" ErrorMessage="Please enter bridge name." ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>

                                <td colspan="2" style="text-align: right; margin-left: 40px;">
                                    <asp:Button ID="btnSearchUser" runat="server" OnClick="btnSearchUser_Click" TabIndex="5"
                                        Text="Search" ValidationGroup="vgSearchMember" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5" style="background-color: White" class="style6">
                                    <asp:Label ID="lblSearchResults" runat="server"></asp:Label>
                                    <asp:GridView ID="gvSearchResults" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                        BackColor="White" BorderWidth="1px" CellPadding="4" CssClass="gridviewBorder"
                                        DataKeyNames="EmpId" ForeColor="Black" GridLines="Horizontal" PageSize="5" RowStyle-CssClass="style5"
                                        TabIndex="7" Width="100%" OnPageIndexChanging="gvSearchResults_PageIndexChanging"
                                        OnRowCommand="gvSearchResults_RowCommand">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkSelect" runat="server" Text="Select" CommandName="Select"
                                                        CommandArgument='<%# Eval("EmpId") %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="EmpId" HeaderText="Employee ID" />
                                            <asp:BoundField DataField="Alias" HeaderText="Username" />
                                            <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                            <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                        </Columns>

                                    </asp:GridView>
                                    <br />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="btnOwner"
                        ExpandControlID="btnOwner" TargetControlID="PnlRegister" Collapsed="true">
                    </asp:CollapsiblePanelExtender>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <br />
                    <asp:Button ID="btnSaveBridge" runat="server" Text="Save" OnClick="btnSaveBridge_Click"
                        ValidationGroup="vldAddBridge" />
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
                    <span style="display: none">
                        <input type="button" id="Cancel" /></span>
                </td>
            </tr>
        </table>
    </asp:Panel>




    Code:
     protected void gvSearchResults_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
                     //some business logic
                    CollapsiblePanelExtender1.Collapsed = true;
                    ModalPopupExtender1.Show();
                }
            }

它不工作面板总是打开的??有什么建议么.....

4

1 回答 1

-1

你不见了

  • tr 在您的设计中。请检查一下

标记:

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnAdd"
        PopupControlID="pnlpopup" CancelControlID="Cancel" BackgroundCssClass="modalBackground">
    </asp:ModalPopupExtender>
    <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="320px" Width="530px"
        Style="display: none">
        <table width="100%" style="border: Solid 3px #D55500; height: 100%" cellpadding="0"
            cellspacing="0">
            <tr>
                <td>
                    Bridge ID :
                    <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvID" runat="server" ControlToValidate="txtID" ValidationGroup="vldAddBridge"
                        ErrorMessage="Please enter ID" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
                <td>
                    Bridge Name :
                    <asp:TextBox ID="txtBridgeName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBridgeName" runat="server" ControlToValidate="txtBridgeName"
                        ValidationGroup="vldAddBridge" ErrorMessage="Please enter bridge name." ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            **<tr> //This is missing**
                                <td colspan="2" style="text-align: right; margin-left: 40px;">
                                    <asp:Button ID="btnSearchUser" runat="server" OnClick="btnSearchUser_Click" TabIndex="5"
                                        Text="Search" ValidationGroup="vgSearchMember" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5" style="background-color: White" class="style6">
                                    <asp:Label ID="lblSearchResults" runat="server"></asp:Label>
                                    <asp:GridView ID="gvSearchResults" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                        BackColor="White" BorderWidth="1px" CellPadding="4" CssClass="gridviewBorder"
                                        DataKeyNames="EmpId" ForeColor="Black" GridLines="Horizontal" PageSize="5" RowStyle-CssClass="style5"
                                        TabIndex="7" Width="100%" OnPageIndexChanging="gvSearchResults_PageIndexChanging"
                                        OnRowCommand="gvSearchResults_RowCommand">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkSelect" runat="server" Text="Select" CommandName="Select"
                                                        CommandArgument='<%# Eval("EmpId") %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="EmpId" HeaderText="Employee ID" />
                                            <asp:BoundField DataField="Alias" HeaderText="Username" />
                                            <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                            <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                        </Columns>

                                    </asp:GridView>
                                    <br />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="btnOwner"
                        ExpandControlID="btnOwner" TargetControlID="PnlRegister" Collapsed="true">
                    </asp:CollapsiblePanelExtender>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <br />
                    <asp:Button ID="btnSaveBridge" runat="server" Text="Save" OnClick="btnSaveBridge_Click"
                        ValidationGroup="vldAddBridge" />
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
                    <span style="display: none">
                        <input type="button" id="Cancel" /></span>
                </td>
            </tr>
        </table>
    </asp:Panel>

希望它能解决你的问题

于 2013-08-07T12:27:55.067 回答