I have a GridView where one of the columns shows a bound date value. When in edit mode, I want to work with a UserControl I created ("SmallCalendar"). The User Control is a simple date selector/display of 3 dropdowns. One each for Month, Day and Year.
When I try to access SmallCalendar, I get the error, "Object reference not set to an instance of an object".
The code I use is:
Code:
Public Sub GridView1_Edit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs)
Dim i As Integer
i = e.NewEditIndex
Dim row As GridViewRow
row = GridView1.Rows(i)
Dim cal As New SmallCalendar
cal = CType(row.Cells(6).FindControl("Calendar1"), SmallCalendar)
TextBox1.Text = cal.SelectedDate_AsString
End Sub
I placed SmallCalendar on the design surface for the Edit Template.
Thanks in advance for your comments.