D
David C
I am trying to toggle a calendar control in a GridView and I am getting the
error "Object reference not set to an instance of an object."
The error is occurring in the 1st FindControl of the code below. I am using
an ImageButton next to a textbox so that when clicked, the calendar will
show.
I have to use FindControl because there are 3 controls in this 1 cell.
Thanks.
Protected Sub IBtnCalTask_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
Dim row As GridViewRow = gvFileTasks.SelectedRow
Dim varCalendar
varCalendar = row.FindControl("calDueDate")
If varCalendar.CssClass = "Hide" Then
Dim varTaskDate
varTaskDate = row.FindControl("txtTaskDate")
If varTaskDate.Text = "" Then
varCalendar.SelectedDate = DateTime.Today.ToShortDateString
Else
varCalendar.SelectedDate = varTaskDate.Text
End If
varCalendar.CssClass = "Show"
Else
varCalendar.CssClass = "Hide"
End If
End Sub
-David
error "Object reference not set to an instance of an object."
The error is occurring in the 1st FindControl of the code below. I am using
an ImageButton next to a textbox so that when clicked, the calendar will
show.
I have to use FindControl because there are 3 controls in this 1 cell.
Thanks.
Protected Sub IBtnCalTask_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
Dim row As GridViewRow = gvFileTasks.SelectedRow
Dim varCalendar
varCalendar = row.FindControl("calDueDate")
If varCalendar.CssClass = "Hide" Then
Dim varTaskDate
varTaskDate = row.FindControl("txtTaskDate")
If varTaskDate.Text = "" Then
varCalendar.SelectedDate = DateTime.Today.ToShortDateString
Else
varCalendar.SelectedDate = varTaskDate.Text
End If
varCalendar.CssClass = "Show"
Else
varCalendar.CssClass = "Hide"
End If
End Sub
-David