嵌套更新面板问题

发布于 2024-11-07 12:16:12 字数 4925 浏览 0 评论 0原文

我有一个嵌套的更新面板 像这样的

<asp:UpdatePanel ID="DetailsUpdatePanel" runat="server" Visible="false" UpdateMode="Conditional" >
    <ContentTemplate>
    <div><ajaxToolkit:AsyncFileUpload runat="server" ID="BrochureUpload" Width="400px"   
            OnClientUploadError="BrochureuploadError"    
            OnClientUploadStarted="BrochureStartUpload"  
            OnClientUploadComplete="BrochureUploadComplete"  
            CompleteBackColor="Lime" UploaderStyle="Modern"    
            ErrorBackColor="Red" ClientIDMode="AutoID"    
            ThrobberID="Throbber"    
            UploadingBackColor="#66CCFF" 
                onuploadedcomplete="BrochureUpload_UploadedComplete"/>
                <asp:Label ID="Label1" runat="server" Style="display: none">
     <asp:Image runat="server" ID="Image1" ImageUrl="~/Images/uploading.gif" />
            </asp:Label>
      <asp:Label ID="brochurelblstatus" runat="server" Style="font-family: Arial; font-size: small;"></asp:Label></div>
     <div><asp:UpdatePanel runat="server" ID="child" UpdateMode="Conditional" >
                <ContentTemplate>
                <div>
     <asp:GridView ID=GridView2" runat="server" AllowPaging="true" AutoGenerateColumns="false" CellPadding="0" CellSpacing="1" DataKeyNames="ArticleId">
        <Columns>
       <asp:BoundField DataField="ArticleId" HeaderText="ArticleId" ReadOnly="True" HeaderStyle-CssClass="td1" />
       <asp:BoundField DataField="FileName" HeaderText="FileName" ReadOnly="True" HeaderStyle-CssClass="td2" />
       <asp:TemplateField HeaderText="BrochureUrl">
       <ItemTemplate>
       <asp:HyperLink ID="lnkEPhoto" runat="server" BorderWidth="2px" NavigateUrl='<%# GetUrl(Eval("ArticleId"),Eval("FileName")) %>'
                    Target="_blank"></asp:HyperLink>
          </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
      <ItemTemplate>
       <asp:LinkButton ID="btnRemove" runat="server" text="Delete" CommandName="Delete" CausesValidation="False" OnClientClick="DeleteOrNo()">
       </asp:LinkButton>
         </ItemTemplate>
       </asp:TemplateField>
         </Columns>
        </asp:GridView>
           </div>

                </ContentTemplate>

                </asp:UpdatePanel></div>
    </ContentTemplate>
    </updatePanel>

CodeBehind:

protected void BrochureUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
                 {
                     if(BrochureUpload.HasFile)
                     {
                         if(BrochureUpload.PostedFile.ContentLength<=3670016 )
                         {
                             var brochurePath = MapPath("~/") + Path.GetFileName(e.filename);
                             BrochureUpload.SaveAs(brochurePath);
                             using (var dataContext = new NewsStandAloneDataContext(Config.StandaloneNewsConnectionString))
                             {
                                 var brochure = new xxx
                                                    {
                                                        Id = Convert.ToInt32(GridView1.SelectedValue),
                                                        FileName = Path.GetFileName(e.filename),
                                                        RecordCreated = DateTime.Now
                                                    };
                                 dataContext.xxx.InsertOnSubmit(brochure);
                                 dataContext.SubmitChanges();
                             }
                             bindGridView();//I have code to bind gridview
    Child.Update();


                         }
                     }
                 }

     protected void bindBrochureGridView()
            {
                using (var dataContext = new NewsStandAloneDataContext(Config.StandaloneNewsConnectionString))
                {
                    var brochureList = (from brochure in dataContext.xxx
                                        where brochure.ArticleId == Convert.ToInt32(GridView2.SelectedValue)
                                        select new ArcticleBrochure
                                                   {
                                                       ArticleId = brochure.ArticleId.ToString(),
                                                       FileName = brochure.FileName

                                                   }).ToList();
                    GridView1.DataSource = brochureList;
                    GridView1.DataBind();        

                }
            }

当我上传文件时,我希望更新子更新面板中的giedview。但它不起作用任何想法??????

提前致谢

I am having a nested update panel
something like this

<asp:UpdatePanel ID="DetailsUpdatePanel" runat="server" Visible="false" UpdateMode="Conditional" >
    <ContentTemplate>
    <div><ajaxToolkit:AsyncFileUpload runat="server" ID="BrochureUpload" Width="400px"   
            OnClientUploadError="BrochureuploadError"    
            OnClientUploadStarted="BrochureStartUpload"  
            OnClientUploadComplete="BrochureUploadComplete"  
            CompleteBackColor="Lime" UploaderStyle="Modern"    
            ErrorBackColor="Red" ClientIDMode="AutoID"    
            ThrobberID="Throbber"    
            UploadingBackColor="#66CCFF" 
                onuploadedcomplete="BrochureUpload_UploadedComplete"/>
                <asp:Label ID="Label1" runat="server" Style="display: none">
     <asp:Image runat="server" ID="Image1" ImageUrl="~/Images/uploading.gif" />
            </asp:Label>
      <asp:Label ID="brochurelblstatus" runat="server" Style="font-family: Arial; font-size: small;"></asp:Label></div>
     <div><asp:UpdatePanel runat="server" ID="child" UpdateMode="Conditional" >
                <ContentTemplate>
                <div>
     <asp:GridView ID=GridView2" runat="server" AllowPaging="true" AutoGenerateColumns="false" CellPadding="0" CellSpacing="1" DataKeyNames="ArticleId">
        <Columns>
       <asp:BoundField DataField="ArticleId" HeaderText="ArticleId" ReadOnly="True" HeaderStyle-CssClass="td1" />
       <asp:BoundField DataField="FileName" HeaderText="FileName" ReadOnly="True" HeaderStyle-CssClass="td2" />
       <asp:TemplateField HeaderText="BrochureUrl">
       <ItemTemplate>
       <asp:HyperLink ID="lnkEPhoto" runat="server" BorderWidth="2px" NavigateUrl='<%# GetUrl(Eval("ArticleId"),Eval("FileName")) %>'
                    Target="_blank"></asp:HyperLink>
          </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
      <ItemTemplate>
       <asp:LinkButton ID="btnRemove" runat="server" text="Delete" CommandName="Delete" CausesValidation="False" OnClientClick="DeleteOrNo()">
       </asp:LinkButton>
         </ItemTemplate>
       </asp:TemplateField>
         </Columns>
        </asp:GridView>
           </div>

                </ContentTemplate>

                </asp:UpdatePanel></div>
    </ContentTemplate>
    </updatePanel>

CodeBehind:

protected void BrochureUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
                 {
                     if(BrochureUpload.HasFile)
                     {
                         if(BrochureUpload.PostedFile.ContentLength<=3670016 )
                         {
                             var brochurePath = MapPath("~/") + Path.GetFileName(e.filename);
                             BrochureUpload.SaveAs(brochurePath);
                             using (var dataContext = new NewsStandAloneDataContext(Config.StandaloneNewsConnectionString))
                             {
                                 var brochure = new xxx
                                                    {
                                                        Id = Convert.ToInt32(GridView1.SelectedValue),
                                                        FileName = Path.GetFileName(e.filename),
                                                        RecordCreated = DateTime.Now
                                                    };
                                 dataContext.xxx.InsertOnSubmit(brochure);
                                 dataContext.SubmitChanges();
                             }
                             bindGridView();//I have code to bind gridview
    Child.Update();


                         }
                     }
                 }

     protected void bindBrochureGridView()
            {
                using (var dataContext = new NewsStandAloneDataContext(Config.StandaloneNewsConnectionString))
                {
                    var brochureList = (from brochure in dataContext.xxx
                                        where brochure.ArticleId == Convert.ToInt32(GridView2.SelectedValue)
                                        select new ArcticleBrochure
                                                   {
                                                       ArticleId = brochure.ArticleId.ToString(),
                                                       FileName = brochure.FileName

                                                   }).ToList();
                    GridView1.DataSource = brochureList;
                    GridView1.DataBind();        

                }
            }

When I upload the file , I want the giedview which is in the child updatepanel to be updated .But it doesnt work Any ideas?????

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的往事 2024-11-14 12:16:12

BrochureUpload_UploadedComplete 事件中调用 child.Update();

 protected void BrochureUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
 {
   ....................
   ....................
   bindGridView();//I have code to bind gridview
   child.Update();
 }

Call child.Update(); in BrochureUpload_UploadedComplete event.

 protected void BrochureUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
 {
   ....................
   ....................
   bindGridView();//I have code to bind gridview
   child.Update();
 }
习ぎ惯性依靠 2024-11-14 12:16:12

文件上传完成后,调用包含gridview的UpdatePanelChild.Update()方法。您需要这样做,因为您设置了 UpdateMode="Conditional" 在这种情况下,您必须在代码中手动更新它。

When file upload is complete then call Child.Update() method of UpdatePanel which contain gridview. You need to do that because you set UpdateMode="Conditional" in this case you have to manually update it in code.

临风闻羌笛 2024-11-14 12:16:12

更新面板中的 ChildrenAsTriggers="True"

ChildrenAsTriggers="True" in your updatepanel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文