回发不会刷新testbox或gridview的内容

时间:2011-08-03 18:43:41

标签: c# asp.net asp.net-ajax

我真的需要帮助。我正在使用AjaxControlToolkit.TabContainer并使用ASP.NET Framework 4.0。 Gridview,文本框和按钮放在asp页面的TabContainer中。当我按下按钮回发确实发生但它没有绑定gridview到datatable和文本框内容也没有更新。

我调试代码并发现当我按下按钮回发确实发生并且内容确实填满了gridview和textbox值也分配了新值。但值不会显示在页面上。我不知道为什么会发生这种情况。请帮忙。

protected void Page_Load(object sender, EventArgs e)
{
  if (IsPostBack)
  {
      if (ListBoxCustomer.Items.Count != 0)
      {
          int[] _selectedItems = ListBoxCustomer.GetSelectedIndices();
          string _comma = "";
          string _custID = "";
          InitializeConnection();
          if (_selectedItems.Length != 0)
          {
              foreach (int i in _selectedItems)
              {
                  _custID = _custID + _comma + ListBoxCustomer.Items[i].Value;
                  _comma = ",";
              }
              if (custObj != null)
              {
                  //DataTable _dt = new DataTable();
                  DataSet _ds = new DataSet();
                  GridViewCustomer.Visible = true;
                  GridViewCustomer.AutoGenerateColumns = true;
                  _ds = custObj.GetSelectedCustomers(1, _custID);
                  GridViewCustomer.DataSource = _ds.Tables[0];
                  GridViewCustomer.DataBind();

                  TextBoxTest.Text = GridViewCustomer.Rows.Count.ToString();
                  TextBoxTest.Text = "test";
              }
          }
      }
  }
}

感谢。

1 个答案:

答案 0 :(得分:1)

也许永远无法访问DataBind代码。您是否设置了一些断点以确保if语句不会阻止您?那就是...... ListBoxCustomer.Items.Count 肯定不是零... custObj 绝对不是null?

您在哪里为custObj分配值?

相关问题