I want to rename column names in GridView in multiple pages. So far, I can change one at a time. Here's my code:
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Columns.Count; i++)
{
if (GridView1.Columns[i].HeaderText == TextBox1.Text)
{
GridView1.Columns[i].HeaderText = TextBox2.Text;
}
}
}
In the design view I have two textboxes and a button. When I click the button it gets textbox1 and renames that column that I typed in textbox2.
What I am trying to do: I have multiple pages and I want to change their column HeaderText. I don't want to add these buttons and textboxes to each page. Is there any way to call this function only once and change the HeaderTexts in all pages?
Thank you in advance.