Solved

Accessing a Custom Control in EditItemTemplate Datalist

Posted on 2004-09-16
4
531 Views
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?

Thanks
0
Comment
Question by:gspronych
  • 2
4 Comments
 
LVL 8

Expert Comment

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

0
 
LVL 3

Author Comment

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

Any other suggestions?
Thanks
0
 
LVL 3

Accepted Solution

by:
gspronych earned 0 total points
ID: 12088850
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net bundle 8 47
Calling stored proc in EDMX 11 23
Display mvc partial view with errors on parent page 1 26
Gridview alignment 1 9
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now