我真的需要帮助。我正在使用AjaxControlToolkit.TabContainer和ASP.NET Framework 4.0。Gridview、textbox和按钮被放置在asp页面的TabContainer中。当我按下按钮回发时,它不会将网格视图绑定到datatable和textbox内容也不会被更新。
我调试代码,并发现当我按下按钮回发时确实会发生,而内容确实填充在网格视图和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";
}
}
}
}
}谢谢。
发布于 2011-08-03 18:54:58
也许DataBind代码是永远无法到达的。您是否设置了一些断点以确保if-语句没有阻塞您?那是..。ListBoxCustomer.Items.Count 绝对不是零..。custObj 肯定不为空吗?
您在哪里为custObj赋值?
https://stackoverflow.com/questions/6931560
复制相似问题