开发者

I need the gridView in the Ajax Update Panel to Bind its new data

I'm talking about ASP.NET Ajax Control Toolkit, GridView and AsyncFileUpload.

I have an UpdatePanel contains: GridView, AsyncFileUpload.

The gridView views fileNames uploaded by the asyncFileUpload.

When I finish uploading a file, the grid view does NOT bind its new data until I do a refresh.

I've tried: gridView.DataBind() in the OnUploadCompleted Event, but it failed.

I'm wondering! I want a line to do a post back inside the ajax to view the new data!

What is the point?

Edit: (Code)

pro开发者_Go百科tected void btnUploadReport(object sender, EventArgs e)
{
    if (fuReports.HasFile)
    {
        try
        {
            string newFileName = fuReports.FileName.Insert(fuReports.FileName.Length - 5, DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString());
            newFileName = Server.MapPath("~/Files/Reports/TextReports/") + newFileName;
            fuReports.SaveAs(newFileName);

            System.Collections.Specialized.ListDictionary item = new System.Collections.Specialized.ListDictionary();

            item.Add("project_id", Request.QueryString["pid"]);
            item.Add("title", fuReports.FileName);
            item.Add("type", "text");
            item.Add("url", newFileName);

            ldsReports.Insert(item); // lds means LinqDataSource

            grdReports.DataBind();

        }
        catch (Exception ex)
        {
            Session["Message"] = ex.Message;
            Response.Redirect("~/Message.aspx");
        }
    }
}


The DataBind is not enough. You need first to update the DataList with the new file names that you upload, then call the DataBind.

If you show the code here I can give you some more details, but this is the case here, the data is not updated on your GridView and that why you not see them

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜