Reference dynamically added controls in HeaderRow gridview
I want to add textbox to headerRow of first column in Gridview and than reference it in button click event. Unfortunatly this doesn't work, any suggestions. Thank you in advance
protected void gridView_RowCreated(object sender, GridViewRowEventArgs e)
{
TextBox tx10=new TextBox();
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Controls.Add(tx10);
}
}
protected void btFilter_Click(object sender, EventArgs e)
{
TextBox tbx = (TextBox)gridView.HeaderRow.FindControl("tx10");
}