Gridview Inside User Control - Cannot Change Column Header Text

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • cloud255
    replied
    Originally posted by Amit00
    col.HeaderText = GetString(col.H eaderText);
    here, you are saying, HeaderText of x = HeaderText of x. unless that GetString function does something really strange (which i doubt) the column will always have the same header text...

    As far as placing the code:

    Create a property, like a collection of strings that will represent the header names. In the properties setter, call the code to change the column headers with the values supplied to the property.

    I would then expose a public event which will allow you to pass a colleciton of type string. The user of the control then needs to override the event...

    Leave a comment:


  • Gridview Inside User Control - Cannot Change Column Header Text

    Hi,
    I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that:

    foreach (DataControlFie ld col in GridView1.Colum ns)
    {
    col.HeaderText = GetString(col.H eaderText);
    }

    However, no matter where I place that code, the header texts return to their original value, and that's what's being displayed.

    What could be the reason for that? And how can it be solved?
Working...