“组合式”Server控件中包含的DataGrid对象,无法响应一些事件
sinzy 2003-09-01 06:08:25 我要以创建“组合式”控件的方式,给DataGrid控件增加一些功能,我的控件的重载的CreateChildControls()方法中写了如下的代码(大致):
this.m_dataGrid1 = new DataGrid()
// “编辑”列
EditCommandColumn eccCol = new EditCommandColumn();
eccCol.HeaderText = "编辑";
eccCol.EditText = "[E]";
eccCol.UpdateText = "[U]";
eccCol.CancelText = "[C]";
m_dgrdShow.Columns.Add(eccCol);
// “删除”列
ButtonColumn btnCol = new ButtonColumn();
btnCol.HeaderText = "删除";
btnCol.CommandName = "delete";
btnCol.Text = "[D]";
m_dgrdShow.Columns.Add(btnCol);
// DataGrid 事件……
m_dgrdShow.ItemCommand += new DataGridCommandEventHandler(m_dgrdShow_ItemCommand);
m_dgrdShow.CancelCommand += new DataGridCommandEventHandler(m_dgrdShow_CancelCommand);
m_dgrdShow.EditCommand += new DataGridCommandEventHandler(m_dgrdShow_EditCommand);
m_dgrdShow.UpdateCommand += new DataGridCommandEventHandler(m_dgrdShow_UpdateCommand);
m_dgrdShow.ItemDataBound += new DataGridItemEventHandler(m_dgrdShow_ItemDataBound);
BuildDataGrid(); // 生成一些显示数据的BoundColumn列对象并添加到DataGrid的列集合中
BindDataGrid(); // 绑定数据
this.Controls.Add(this.m_dgrdShow);
现在,我可以正常的显示数据,并能够响应EditCommand事件,但是UpdateCommand和CancelCommand事件则无法响应(用断点测试得知)……
郁闷无比,请各位高人指点~
我觉得问题原因可能是页面事件引发顺序的问题,我的自定义控件少了一道什么工序……