Assign GridView columns dynamically

  • Thread starter Thread starter cashdeskmac
  • Start date Start date
C

cashdeskmac

Hi,

I have a GridView that is going to show data based on office opening and
closing times. I would like to look at the opening and closing time and the
length of the time slots (15 mins, 20 mins, etc) and create the columns
dynamically.

I thought about creating a GridViewRowCollection and assigning it to the
GridView.Rows collection, but the Rows collection is readonly, so that
approach is out.

Is there any other way to generate columns at runtime?
 
if you are trying to create cells dynamicly so that they are not even, row 1
has 5 cells, row two has 3 cells, ..., you will need to build them at run
time. If you are just generating a collection of rows that will change the
number of columns depending on the time of day look into creating a generic
list of objects and bind this to a gridview at run time.
 
Back
Top