473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How set Calendar defaultdate in FormView

I have a formview control.

When the user goes into insert mode I want to set the Calendar to today's
date.

How can I accomplish this? I know it's probably only 1 or 2 lines of code.

I tried this, but it doesn't work..
Protected Sub FormView1_ModeChanging(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewModeEventArgs) Handles
FormView1.ModeChanging
If e.NewMode = FormViewMode.Insert Then
Dim cal As Calendar =
CType(Me.FormView1.Row.FindControl("calDeadline"), Calendar)
cal.SelectedDate = Now.Date
End If
End Sub

Thanks!
Nov 2 '07 #1
4 1783
Hello Cirene,

What exactly doesn't work? You can't find the control, or the date not changes
---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
CModeChanging(ByVal sender As Object, ByVal e As
CSystem.Web.UI.WebControls.FormViewModeEventArgs) Handles
CFormView1.ModeChanging
CIf e.NewMode = FormViewMode.Insert Then
CDim cal As Calendar =
CCType(Me.FormView1.Row.FindControl("calDeadline") , Calendar)
Ccal.SelectedDate = Now.Date
Nov 3 '07 #2
After I set it it is still Nothing.

<Michael Nemtsev>; "MVP" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
Hello Cirene,

What exactly doesn't work? You can't find the control, or the date not
changes
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

CModeChanging(ByVal sender As Object, ByVal e As
CSystem.Web.UI.WebControls.FormViewModeEventArgs) Handles
CFormView1.ModeChanging
CIf e.NewMode = FormViewMode.Insert Then
CDim cal As Calendar =
CCType(Me.FormView1.Row.FindControl("calDeadline") , Calendar)
Ccal.SelectedDate = Now.Date


Nov 3 '07 #3
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

"Cirene" <te**@test.comwrote in message
news:u2**************@TK2MSFTNGP03.phx.gbl...
After I set it it is still Nothing.

<Michael Nemtsev>; "MVP" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
>Hello Cirene,

What exactly doesn't work? You can't find the control, or the date not
changes
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CModeChanging(ByVal sender As Object, ByVal e As
CSystem.Web.UI.WebControls.FormViewModeEventArg s) Handles
CFormView1.ModeChanging
CIf e.NewMode = FormViewMode.Insert Then
CDim cal As Calendar =
CCType(Me.FormView1.Row.FindControl("calDeadline" ), Calendar)
Ccal.SelectedDate = Now.Date



Nov 3 '07 #4
Hello Cirene,

Well... it means that you can't find the real Callendar control to set the
date

View the page source to check that you are looking for the correct control
name

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
CObject reference not set to an instance of an object.
CDescription: An unhandled exception occurred during the execution of
Cthe
Ccurrent web request. Please review the stack trace for more
Cinformation
Cabout the error and where it originated in the code.
CException Details: System.NullReferenceException: Object reference
Cnot set to an instance of an object.
C>
C"Cirene" <te**@test.comwrote in message
Cnews:u2**************@TK2MSFTNGP03.phx.gbl...
C>
>After I set it it is still Nothing.

<Michael Nemtsev>; "MVP" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsof t.com...
>>Hello Cirene,

What exactly doesn't work? You can't find the control, or the date
not changes

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and
we miss it, but that it is too low and we reach it" (c) Michelangelo
CModeChanging(ByVal sender As Object, ByVal e As
CSystem.Web.UI.WebControls.FormViewModeEventArgs ) Handles
CFormView1.ModeChanging
CIf e.NewMode = FormViewMode.Insert Then
CDim cal As Calendar =
CCType(Me.FormView1.Row.FindControl("calDeadline "), Calendar)
Ccal.SelectedDate = Now.Date

Nov 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
1
by: Dabbler | last post by:
I'm trying to customize calendar days using data in a table. Some days may have corresponding rows in the table giving counts for that day. I'm not clear on when I should get the data from the...
1
by: Loading name... | last post by:
Hey asp.net 2.0 I have a FormView on my webpage. This FormView's datasource is a SqlDataSource object. This SqlDataSource returns 1 datetime field. So I've added a Calendar control to the...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
2
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
0
by: trubble | last post by:
Hi I've been googling for AGES but still no joy so would really appreciate help!! I have a form view with a calendar control in it's edit item template. It displays the date from the database...
2
by: David C | last post by:
Using .Net 2 and VS2005. I have a calendar control in a TD cell of a table in the edit template of a FormView. I have the calendar .Visible property set to false but the control still uses up all...
2
by: DotNetNubie66 | last post by:
I have a Master page that wraps my content pages, on one page I have a FormView that is tied to an ObjectDataSource and has textbox and calendar controls bound to the datasource. My problem is this,...
0
by: cs_in_va | last post by:
I have a calendar (Cal1) inside a formview (fv) when the date is chanded I want to display the date on the label, vlblDate. Protected Sub Cal1_SelectionChanged(ByVal sender As Object, ByVal e...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.