Hi Trevor,
Does the suggestion in my last reply helps a little? If there're anything
else we can help, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 118544060
| References: <umqUpn4#
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Thu, 08 Dec 2005 06:21:21 GMT
| Subject: RE: Calendar Control InvalidCastException
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| Message-ID: <MtjZg#7#
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| Lines: 87
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:14869
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Trevor,
|
| Welcome to ASPNET newsgroup.
| As for the Calendar Control InvalidCastException problem you mentioned, I
| think we may consider manually customizing the DataBound data for that
| TemplateField since sometimes the field dosn't contain value...... For
| example, if you define the following Template in DetailsView:
|
| ===================
| <asp:TemplateField >
| <ItemTemplate>
| <asp:Calendar ID="Calendar1" runat="server"
| VisibleDate='<%# Bind("HireDate") %>'
| SelectedDate='<%# Bind("HireDate") %>' >
|
| </asp:Calendar>
| </ItemTemplate>
|
| </asp:TemplateField>
| ==================
|
| Then, we can define a helper function in page's codebehind class which do
| some customization on the original databound data. e.g:
|
| ======helper function defined in page class...=======
| protected DateTime GetHireDate(DateTime date)
| {
| //customize it here.....
|
| return date;
| }
|
|
| =======detailsview template=======
| <asp:TemplateField >
| <ItemTemplate>
| <asp:Calendar ID="Calendar1" runat="server"
| VisibleDate='<%# GetHireDate((DateTime)Eval("HireDate"))
%>'
| SelectedDate='<%#
GetHireDate((DateTime)Eval("HireDate"))
| %>' >
|
| </asp:Calendar>
| </ItemTemplate>
|
| </asp:TemplateField>
|
| =======================
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
| --------------------
| | From: "Trevor Bezotte" <
[email protected]>
| | Subject: Calendar Control InvalidCastException
| | Date: Wed, 7 Dec 2005 17:57:00 -0600
| | Lines: 27
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <umqUpn4#
[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| | NNTP-Posting-Host: global.erdman.com 12.20.65.30
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.datagridcontrol:14867
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| |
| | Hi,
| |
| | I have a calendar control in an EditItemTemplate on a DetailsView which
| | works fine, until I switch to a record in Edit mode which has no date
in
| | that field.
| |
| | Here is the error:
| |
| | System.InvalidCastException was unhandled by user code
| | Message="Specified cast is not valid."
| | Source="App_Web_cul7wear"
| | StackTrace:
| | at ASP.masterdetail_aspx.__DataBinding__control27(Object sender,
| | EventArgs e) in c:\Inetpub\wwwroot\AppsWeb\MasterDetail.aspx:line 54
| | at System.Web.UI.Control.OnDataBinding(EventArgs e)
| | at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
| | at System.Web.UI.Control.DataBind()
| | at System.Web.UI.Control.DataBindChildren()
| |
| | How do I work around this error, is there a way to code a default in
case
| | there's no date in the field?
| |
| | Thank you.
| |
| | Trevor
| |
| |
| |
|
|