Accessing controls defined in second header in gridview

Posted by Nixan01 under ASP.NET on 1/10/2012 | Points: 10 | Views : 1187 | Status : [Member] | Replies : 0
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);
}




Responses

(No response found.)

Login to post response