Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
739
Can't figure out how to access headers
posted

I have a WebDataGrid that I bind dynamically by setting its data source to a DataTable.  This works fine, but I can't seem to get at the headers programmatically to change the captions, etc.  I want to do this server side.  It seems like it would be easy.  Things I tried:

 1) Accessing the Columns collection during various control events.  However, Columns.Count is always 0.  I put this code in every single event handler:

      if (gridTickets.Columns.Count > 0)

             Debugger.Break();

and it never seems to get populated.

 2) I see a protected HeaderCaptions collection, but that doesn't seem write.

 All I want to do is set some basic properties of the headers as the grid loads.  It's a read-only grid with no paging, so I guess I could just use a repeater or program an ASP table ... any ideas?

 

  • 14049
    Offline posted
    The columns should be set up either at design time or added at runtime
    before you call databind. AutoGenerateColumns should be set to false in
    that case.