I have this gridView:
Here is code that binds data to GridView control:
protected void Page_Load(object sender, EventArgs e)
{
string alias_Title = blabla1;
string alias_Tip = blabla2;
var result = fim.getFeaturesList();
gvFeatList.DataSource = result.featureDesc;
gvFeatList.DataBind();
}
As you can see I have some property called featureDesc and I bind it to data source.
Also in Page_Load event I have two variables called alias_Title and alias_Tip.
I need to display alias_Title instead of Title and alias_Tip instead of Tip.
So my question is, how can I make HeaderText in TemplateFields to be displayed variable alias_Title and alias_Tip.
解决方案
You can set the Text of a HeaderRow Cell after DataBind is called.
gvFeatList.DataBind();
gvFeatList.HeaderRow.Cells[0].Text = alias_Title;
gvFeatList.HeaderRow.Cells[1].Text = alias_Tip;