How can I add Gridview columns dynamically based on calender days? The header of the grid should show dates 01/01/2013, 02/01/2013...and each column is a TemplateField with a Dropdownlist
I achieved this for the weekly view since the fields are constant (7 fields) but when it comes to the month view I cannot add 30 or 31 fields because I've coded in ASP not on code behind C#.
Can anybody give me some hints on how to create a month calendar in this way?
I already tried these links but it didn't help
You can try doing something like this:
DataTable dt = new DataTable();
DataColumn dcol = new DataColumn("ID", typeof(System.Int32));
dcol.AutoIncrement = true;
dt.Columns.Add(dcol);
int days = 0;
string selected_month = "JAN";
if (selected_month == "JAN" || selected_month == "MAR")
{ days = 31; }
else if(selected_month == "APR")
{ days = 30; }
for (int z = 1; z < days; z++)
{
dcol = new DataColumn(z.ToString(), typeof(System.String));
dt.Columns.Add(dcol);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.