Dynamically change datagrid column @ runtime

Results 1 to 2 of 2

Thread: Dynamically change datagrid column @ runtime

  1. #1
    Join Date
    Dec 1969

    Default Dynamically change datagrid column @ runtime

    Is there a way to change a datagrids column text at runtime based on query values?<BR><BR>Scenario: I have a datagrid that pulls records from a stored procedure and I want to name 4 or 5 of the columns with a value that persists in each record.<BR><BR>It&#039;s for a time card web app and I need depending on the month for 4 or 5 of the columns to be named by the work week or start date of the week. So the header would obvoiusly change depending on which month you pick.<BR><BR>I tried a couple of things with the header template in the template column but that didn&#039;t seem to like me changing the text based on a container value like you can do with the item template.<BR><BR>I don&#039;t have any code at this point as I scraped the idea since I couldn&#039;t find any one talking about this on a few message boards. It seems like it should be so easy to do with C# but I can&#039;t find any doc&#039;s with examples.<BR><BR>Thanks,<BR>Jim

  2. #2

    Default RE: Dynamically change datagrid column @ runtime

    Should be straight forward...<BR>You can dig down to the Columns Collection and set each column&#039;s HeaderText<BR><BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridcolumncollectio nclasstopic.asp<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridcolumnmembersto pic.asp<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts