UpdatePanel Gridview not updating

前端 未结 3 1740
心在旅途
心在旅途 2021-01-13 22:12

For some reason, I can\'t get the Gridview in the Updatepanel to refresh after I\'ve made changes. can someone help?

I\'m using the ToolkitScriptManager control and

3条回答
  •  旧时难觅i
    2021-01-13 22:19

    Here is my code for your question

    ASPX FILE

    
        

    CODE BEHIND FILE

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var Employee = new { EmpID = 1, EmpName = "Rahul Jain", Department = "IT", Age = 33, Address = "Hello" };
                var customerList = (new[] { Employee }).ToList();
                customerList.Add(new { EmpID = 2, EmpName = "Sheetal Jain", Department = "IT", Age = 33, Address = "Hello" });
                GridView1.DataSource = customerList;
                GridView1.DataBind();
            }
        }
        protected void Button1_Click1(object sender, EventArgs e)
        {
            try
            {
                var Employee = new { EmpID = 1, EmpName = "Rahul Jain", Department = "IT", Age = 33, Address = "Hello" };
                var customerList = (new[] { Employee }).ToList();
                customerList.Add(new { EmpID = 2, EmpName = "Sheetal Jain", Department = "IT", Age = 33, Address = "Hello" });
                customerList.Add(new { EmpID = 2, EmpName = "Minakshi Jain", Department = "IT", Age = 33, Address = "Hello" });
                GridView1.DataSource = customerList;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    

    This Code Dosent Created the postback for me hope it will work for you as well....

提交回复
热议问题