Mata

Mata

  • NA
  • 46
  • 34.7k

Reference dynamically added controls in HeaderRow gridview

Dec 5 2011 9:30 AM
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");


    }


Answers (1)