I have created second header with couple of textboxes in prerender event. I would like to access text of these textboxes when search button (which is outside of gridview) is selected.
Any help is welcome.
protected void gvTheGrid_PreRender(object sender, EventArgs e)
{
//Dont populate second header if no records in DB
if (bNorecords)
return;
GridViewRow gv = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
gv.ID = "SecondRow";
for (int j = 0; j < 4; j++)
{
TableCell cell = new TableCell();
TextBox tb = new TextBox();
tb.Width = 100;
tb.CssClass = "HeaderTextbox";
// Set a unique ID for each TextBox added
tb.ID = "TextBoxRow_" + j;
// Turn Enter key off
tb.Attributes.Add("onkeydown", " return (event.keyCode!=13)");
// Add the control to the TableCell
cell.Controls.Add(tb);
gv.Cells.Add(cell);
}
TableCell tbCell = new TableCell();
tbCell.ColumnSpan = 2;
tbCell.Enabled = false;
gv.Cells.Add(tbCell);
gvTheGrid.Controls[0].Controls.AddAt(bViewAll ? 1 : 2, gv);
}