I have two different views in my ASP.Net application. I have a list view and a calendar view. I am trying to get the link to perform differently under certain circumstances. If the the class is full the link should be disabled and read class full. If there are available spots it should allow people to click on the link. If it is past the registration closed date of the class it should tell them that and not let them click on the link. Everything is working except the registration closed part. Here is my code for the list view. It is in a grid view:
listLink.NavigateUrl = "~/List.aspx?eventAuid=" + Request.QueryString["eventAuid"];
monthlyCalendarLnk.NavigateUrl = "~/Calendar.aspx?eventAuid=" + Request.QueryString["eventAuid"];
for (int a = 0; a < eventOccurrencesGV.Rows.Count; a++)
{
if (eventOccurrencesGV.Rows[a].Cells[7].Text == "0")
{
eventOccurrencesGV.Rows[a].Cells[8].Text = "Class Full";
}
if (eventOccurrencesGV.Rows[a].Cells[2].Text < DateTime.Now)
{
eventOccurrencesGV.Rows[a].Cells[8].Text = "Registration Closed";
}
}
Here is how the gridview is set up:
<asp:GridView ID="eventOccurrencesGV" runat="server" DataSourceID="listGridViewDS" AutoGenerateColumns="False"
OnSelectedIndexChanged="eventOccurrencesGV_SelectedIndexChanged" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="eventAuid" HeaderText="eventAuid" ReadOnly="True" SortExpression="eventAuid"
InsertVisible="False" Visible="False" />
<asp:BoundField DataField="eventOccurrencesAuid" HeaderText="eventOccurrencesAuid"
SortExpression="eventOccurrencesAuid" InsertVisible="False" ReadOnly="True" Visible="False" />
<asp:BoundField DataField="eventRegistrationClosed"
SortExpression="eventRegistrationClosed" Visible="False" />
<asp:BoundField DataField="dayOfWeek" HeaderText="Day Of Week" SortExpression="dayOfWeek"
ReadOnly="True" />
<asp:BoundField DataField="startDateTime" HeaderText="Start Date/Time" SortExpression="startDateTime" />
<asp:BoundField DataField="endDateTime" HeaderText="End Date/Time" SortExpression="endDateTime" />
<asp:BoundField DataField="location" HeaderText="Location"
SortExpression="location" />
<asp:BoundField DataField="remainingSpots" HeaderText="Remaining Spots" SortExpression="remainingSpots">
</asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="eventAuid,eventOccurrencesAuid"
DataNavigateUrlFormatString="SignUpForAnEventOccurrence.aspx?eventAuid={0}&eventOccurrencesAuid={1}"
Text="Sign up" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Here is my code for the calendar view:
if (numberOfEventsForDay > 0)
{
e.Cell.Controls.Add(new LiteralControl(@"<span style=""text-align:center""><br />"));
for (int i = 0; i < numberOfEventsForDay; i++)
{
if (i > 0)
{
e.Cell.Controls.Add(new LiteralControl("<hr />"));
}
string regCloseDate = ds.Tables[0].Rows[i]["eventRegistrationClosed"].ToString();
string startDateTime = ds.Tables[0].Rows[i]["startDateTime"].ToString();
string endDateTime = ds.Tables[0].Rows[i]["endDateTime"].ToString();
string formatStartDateTime = DateTimeFormatting(startDateTime);
string formatEndDateTime = DateTimeFormatting(endDateTime);
string formatRegistrationClosed = DateTimeFormatting(endDateTime);
string eventOccurrencesAuid = ds.Tables[0].Rows[i]["eventRegistrationClosed"].ToString();
string location = ds.Tables[0].Rows[i]["location"].ToString();
string remainingSpots = ds.Tables[0].Rows[i]["remainingSpots"].ToString();
HyperLink eventHpl = new HyperLink();
eventHpl.Font.Size = FontUnit.Point(7);
if (int.Parse(remainingSpots) <= 0)
{
eventHpl.Text = formatStartDateTime + "-" + formatEndDateTime + " " + location + " (FULL)";
}
if (formatRegistrationClosed < DateTime.Now)
{
eventHpl.Text = formatStartDateTime + "-" + formatEndDateTime + " " + location + " (REGISTRATION CLOSED)";
}
else
{
eventHpl.Text = formatStartDateTime + "-" + formatEndDateTime + " " + location + " (" + remainingSpots + ")";
eventHpl.NavigateUrl = "SignUpForAnEventOccurrence.aspx?eventAuid=" + eventAuid + "&eventOccurrencesAuid=" + eventOccurrencesAuid;
}
e.Cell.Controls.Add(eventHpl);
}
}
e.Cell.Controls.Add(new LiteralControl(@"</span>"));
}
The error I am getting for both of these is:
"Operator '<' cannot be applied to operands of type 'string' and 'System.DateTime'"
I tried first to have string equal to DateTime.Now but that did not work either. So I do not know how to fix my issue. If anybody can help I would apprieciate it.
Thank you.