Thegridisalreadybeingmountedcorrectly.ButwhenIgiveaPostBackbyclickingonabuttononthepage,thegridstaysandonlytheheaders(purplelines)disappear.IknowifIcallthemethodtoreloadthegridagain,itworks,butitdoesnotseemtometobeagoodthingtodo.
Codeforcreatingdynamicheaders.
protectedvoidgrvAvaliacao_RowDataBound(objectsender,GridViewRowEventArgse){if(e.Row.RowType==DataControlRowType.DataRow){//SemudaroHeadif(!DataBinder.Eval(e.Row.DataItem,"NAT_Nome").Equals(Session["Competencia"]))
{
Session["Competencia"] = DataBinder.Eval(e.Row.DataItem, "NAT_Nome");
this.head = true;
}
if (this.head)
{
GridViewRow linha = CriarCabecalho(e);
//linha -> tabela
var tabela = e.Row.Parent as Table;
tabela.Rows.AddAt(tabela.Rows.Count - 1, linha);
this.head = false;
}
}
}