大家好。我有一个像这样的嵌套更新面板
<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>
代码隐藏:
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。但它不起作用任何想法?????
提前致谢