Accessing a Custom Control in EditItemTemplate Datalist

Posted on 2004-09-16
Medium Priority
Last Modified: 2008-01-09
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?

Question by:gspronych
  • 2

Expert Comment

ID: 12079993
Try using
e.Item.Cells(0).Controls(0)  'Replace the zeros with the proper indices
 instead of e.Item.FindControl?


Author Comment

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

Any other suggestions?

Accepted Solution

gspronych earned 0 total points
ID: 12088850
Thanks for you help, but I figured it out.

I had to fully qualify the control name,
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).

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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.

Join & Write a Comment

There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
Through the video, you can check the migration process of Outlook PST file to PDF. Kernel for Outlook to PDF tool can convert Outlook emails with all attributes like Subject, To, From, Cc, Bcc and other folders such as Inbox, Outbox, Sent Items, Jun…
Did you know PowerShell can save you time with SaaS platforms? Simply leverage RESTfulAPIs to build your own PowerShell modules. These will kill repetitive tickets and tabs, using the command Invoke-RestMethod. Tune into this webinar to learn how…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question