BoundField
カスタムのカスタム(列) を作成しようとしていますGridView
。FooterRow
列のフィルタリングを管理するために、にテキスト ボックスを追加しました。うまく表示されますが、TextChanged
イベントが発生することはありません。ポストバックごとにテキストボックスが再作成され、永続化されていないためだと思います。
これが私のコードです:
public class Column : BoundField
{
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
base.InitializeCell(cell, cellType, rowState, rowIndex);
if (cellType == DataControlCellType.Footer)
{
TextBox txtFilter = new TextBox();
txtFilter.ID = Guid.NewGuid().ToString();
txtFilter.Text = "";
txtFilter.AutoPostBack = true;
txtFilter.TextChanged += new EventHandler(txtFilter_TextChanged);
cell.Controls.Add(txtFilter);
}
}
protected void txtFilter_TextChanged(object sender, EventArgs e)
{
// Never get here
}
}
チェックボックスで試してみましたが、うまくいきました。