更新面板似乎没有更新

时间:2009-10-20 20:02:32

标签: c# asp.net vb.net visual-studio modalpopupextender

我在gridview的模板字段中有一个按钮。 Onclick我想按下按钮打开一个模态弹出窗口,同时强制更新模板弹出窗口中的updatepanel和formview,因为formview的数据源依赖于我在点击后设置的隐藏字段。

这是我到目前为止所做的。

protected void bttnEdit_Click2(object sender, ImageClickEventArgs e)
{
    ImageButton bttnEdit = (ImageButton)sender;

    HiddenField HiddenField1 = (HiddenField)FormView1.FindControl("HiddenField1");
    HiddenField1.Value = bttnEdit.CommandArgument;

    UpdatePanel UpdatePanel3 = (UpdatePanel)FormView1.FindControl("UpdatePanel3");


    AjaxControlToolkit.ModalPopupExtender ModalPopupExtender1 = (AjaxControlToolkit.ModalPopupExtender)FormView1.FindControl("ModalPopupExtender1");
    ModalPopupExtender1.Show();
    FormView3.DataBind();
    UpdatePanel3.Update();

}

我看到弹出窗口,但内部负载没有任何内容。我做错了什么?

<asp:TemplateField ShowHeader="False">
    <EditItemTemplate>
    </EditItemTemplate>
    <ItemTemplate>
        <asp:UpdatePanel ID="UpdatePanel21" runat="server">
            <ContentTemplate>
                <asp:ImageButton ID="bttnEdit" CommandArgument = '<%# Eval("Id") %>' runat="server" OnClick ="bttnEdit_Click2" injid='<%# Eval("Id") %>' causeid='<%# Eval("C_Type") %>' natureid='<%# Eval("n_type") %>' CausesValidation="False" ImageUrl="~/images/bttnEdit.gif" Text="Edit" OnClientClick ="loadmodal(this.injid,this.causeid,this.natureid);"  />
            </ContentTemplate>
        </asp:UpdatePanel>
        &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/bttnDelete.gif" Text="Delete" />
    </ItemTemplate>

<asp:Panel ID = "Pnlmodal" runat ="server" style="background-color:White; padding:1em 6px;">  
    <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode ="Conditional" ChildrenAsTriggers ="true"   >
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID ="Button1" EventName ="Click" />
        </Triggers>
    <ContentTemplate>
        <asp:FormView ID="FormView2" runat="server" DefaultMode ="Edit" DataSourceID ="SqlDataSource8">
            <EditItemTemplate>
                <table>
                    <tr>
                        <td colspan="2" align="center" style="color:Blue;font-size:large">Edit Injury</td>
                    </tr>
                    <tr>
                        <td align="right" ><strong>What event caused the injury </strong></td>                 
                        <td align="left">                                                                                                                <asp:UpdatePanel ID="UpdatePanel14" runat="server">
                                 <ContentTemplate>
                                     ////stuff
                                 </ContentTemplate>
                             </UpdatePanel>

1 个答案:

答案 0 :(得分:0)

您的模式中的FormView名为 FormView2 但是您的代码Databinds FormView3 。 你可能碰巧绑定了错误的FormView