目前我正在使用未绑定的GridView,它有RowUpdating事件来编辑/更新数据到db。我还使用RowDataBound事件为所有列分组子标题。 但是我注意到,自添加RowDatabound以来,RowUpdating事件根本没有被触发。删除RowDataBound的那一刻,程序就像往常一样工作。
我需要使用一个主标题对Sub Headers进行分组。这个问题背后的原因是什么? 我可以解决哪些解决方案,并根据要求实现目标。
编辑:评论中每个请求的代码;
///<summary>
///Adding sub headers to gridview
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
//columns
GridViewRow outerGridView = e.Row;
if (outerGridView.RowType == DataControlRowType.Header)
{
GridViewRow gvrow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell cell0 = new TableCell();
cell0.Text = "Project Details";
cell0.HorizontalAlign = HorizontalAlign.Center;
cell0.ColumnSpan = 6;
TableCell cell1 = new TableCell();
cell1.Text = "Monday";
cell1.HorizontalAlign = HorizontalAlign.Center;
cell1.ColumnSpan = 2;
TableCell cell2 = new TableCell();
cell2.Text = "Tuesday";
cell2.HorizontalAlign = HorizontalAlign.Center;
cell2.ColumnSpan = 2;
TableCell cell3 = new TableCell();
cell3.Text = "Wednesday";
cell3.HorizontalAlign = HorizontalAlign.Center;
cell3.ColumnSpan = 2;
GridView2.Controls[0].Controls.AddAt(0, gvrow);
}
}