Accessing a Custom Control in EditItemTemplate Datalist

I have a custom control in the EditItemTemplate of a  Datalist.
The custom control is called mspwc:DatePicker, which is a datepicker with a DHTML calendar.

The control works fine in the EditItemTemplate, but the problem I have is accessing the value of the control to save it to a database.
I normally use this statement to recover EditItemTemplate values;
Dim strMemberName As String = CType(e.Item.FindControl("ddlMemberName"), DropDownList).SelectedItem.Value

When I try to replace DropDownList with the DatePicker it is not recognized.

Any suggestions on how I can recover the datepicker values, or suggestions on how I can do something similar?

Thanks
LVL 3
gspronychAsked:
Who is Participating?
 
gspronychConnect With a Mentor Author Commented:
Thanks for you help, but I figured it out.

I had to fully qualify the control name,
ie
Dim strTargetDT As String = CType(e.Item.FindControl("dpTarget"), MSPress.WebControls.DatePicker).SelectedDate

I checked all over the net and couldn't find anything similar.
Hopefully this solution will help someone else not waste an entire day (like me).
0
 
boulder_bumCommented:
Try using
e.Item.Cells(0).Controls(0)  'Replace the zeros with the proper indices
 instead of e.Item.FindControl?

0
 
gspronychAuthor Commented:
Thanks for the suggestion, but 'Cells' is not a member of System.Web.UI.WebControls.DataListItem

Any other suggestions?
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.