In a web application, how can I find the controls in header, and how can I bind the value dynamically to those controls? This is what my gridview looks like…
----------------------------------------------
| October | November |
product| | |
| self | Officer | self | officer|
----------------------------------------------
This is my gridview header. All are labels, now I want to find the label (october, noverber, self, officer..) how can I bind the data to them dynamically?
I have following code in gridview rowdatabound event.
foreach (GridViewRow gr in grdProducts.Rows)
{
if (e.Row.RowType == DataControlRowType.Header)
{
Label lM = (Label)gr.FindControl("lblMon1");
lM.Text = month1 + "-" + year1;
lM = (Label)gr.FindControl("lblMon2");
lM.Text = month2 + "-" + year2;
lM = (Label)gr.FindControl("lblMon3");
lM.Text = month3 + "-" + year3;
}
}
Check out this example…. @Surya sasidhar
In Aspx page.. I added below gridview
At code behind page, I added below code…..
Here is the result….