Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Can you please give me an example of how to change the caption of a gridview's column at runtime?

                                0

                                Hi Michael,

                                Unless I'm mistaken, I assume that you wish to change the caption of a column within a client-side script, right? If so, the ASPxGridView doesn't support this functionality, sorry. Using the callback technology is not a good option either, since in this situation the control's ViewState isn't updated, and so the column's caption will be restored once the GridView's layout is modified (for instance, if you group or sort data, change the column's position, etc.). So, it looks as if the only way to accomplish this task is to initiate a postback and change the caption on the server side. Attached is a small sample project that demonstrates this approach. Please try it and let us know your results.

                                Thanks,
                                Vito

                                0

                                Perhaps I could have been clearer. Assume I have a generically named column named "CustomColumn1". Also assume that I have a configuration setting "CustomColumn1Name" that would contain a configurable name for that custom column. Prior to displaying the grid, I need to be able to change that grid-colunm's displayed header caption to the text contained within my "CustomColumn1Name". It should all be able to occur prior to rendering the page, and it feels like it should be simple (yet I am missing it somehow).

                                0

                                Hi Michael,

                                Thank you for the response.

                                If I correctly understand your objective, I suggest that you handle the Page's Load event for this purpose. Here you can use the ASPxGridView.Columns collection to access the required column, and finally use its Caption property to adjust its caption as required. For more information, please refer to the "ASPxGridView.Columns Property" topic in the ASPxGridView documentation.

                                If you're experiencing any difficulty with implementing this functionality, we'll be happy to help you address it. Just describe the problem you ran into in as much detail as possible, so that we can find the most appropriate solution for you.

                                Thanks,
                                Vito

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners