DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 12 Aug 2007 10:49:45 -0400,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    pvong phillip*at*yahoo*dot*com
          2    Alexey Smirnov
                 3    pvong phillip*at*yahoo*dot*com


Why this error message?   
VB.NET / ASP.NET

I have a simple test.  One simple Formview connected to a datasource.  I 
have Button1 outside of the Formview.  The Formview starts in ReadOnlyMode. 
All I want to do is on the button click, change the formview to Insert mode 
and then put the current date in the date textbox.  The date textbox ID is 
DateTextBox and I've double check that to make sure it's right.  Here's my 
simple code.

Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As 
System.EventArgs)

FormView1.ChangeMode(FormViewMode.Insert)

Dim datetb As TextBox = FormView1.FindControl("DateTextBox")

datetb.Text = Now.Date.ToShortDateString()

End Sub


This is the error message I'm getting.

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.

Source Error:

Line 6:          FormView1.ChangeMode(FormViewMode.Insert)
Line 7:          Dim datetb As TextBox = 
FormView1.FindControl("DateTextBox")
Line 8:          datetb.Text = Now.Date.ToShortDateString()
Line 9:      End Sub
Line 10: </script>


Thanks in advance!
Phil
Date:Sun, 12 Aug 2007 10:49:45 -0400   Author:  

Re: Why this error message?   
On Aug 12, 4:49 pm, "pvong" <phillip*at*yahoo*dot*com> wrote:

> VB.NET / ASP.NET
>
> I have a simple test.  One simple Formview connected to a datasource.  I
> have Button1 outside of the Formview.  The Formview starts in ReadOnlyMode.
> All I want to do is on the button click, change the formview to Insert mode
> and then put the current date in the date textbox.  The date textbox ID is
> DateTextBox and I've double check that to make sure it's right.  Here's my
> simple code.
>
> Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> FormView1.ChangeMode(FormViewMode.Insert)
>
> Dim datetb As TextBox = FormView1.FindControl("DateTextBox")
>
> datetb.Text = Now.Date.ToShortDateString()
>
> End Sub
>
> This is the error message I'm getting.
>
> 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.
>
> Source Error:
>
> Line 6:          FormView1.ChangeMode(FormViewMode.Insert)
> Line 7:          Dim datetb As TextBox =
> FormView1.FindControl("DateTextBox")
> Line 8:          datetb.Text = Now.Date.ToShortDateString()
> Line 9:      End Sub
> Line 10: </script>
>
> Thanks in advance!
> Phil


Hi Phil

Are there any entry in the datasource?
Date:Sun, 12 Aug 2007 08:00:20 -0700   Author:  

Re: Why this error message?   
Yes, there are entries in the Datasource.  If I manually put the date in, it 
works perfectly.  I just want when the user clicks this button for the 
formview to auto switch to Insert mode and auto put in today's date for them 
in the datetb.
Thanks!
Phil


"Alexey Smirnov"  wrote in message 
news:1186930820.570788.158710@22g2000hsm.googlegroups.com...

> On Aug 12, 4:49 pm, "pvong" <phillip*at*yahoo*dot*com> wrote:
>> VB.NET / ASP.NET
>>
>> I have a simple test.  One simple Formview connected to a datasource.  I
>> have Button1 outside of the Formview.  The Formview starts in 
>> ReadOnlyMode.
>> All I want to do is on the button click, change the formview to Insert 
>> mode
>> and then put the current date in the date textbox.  The date textbox ID 
>> is
>> DateTextBox and I've double check that to make sure it's right.  Here's 
>> my
>> simple code.
>>
>> Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>>
>> FormView1.ChangeMode(FormViewMode.Insert)
>>
>> Dim datetb As TextBox = FormView1.FindControl("DateTextBox")
>>
>> datetb.Text = Now.Date.ToShortDateString()
>>
>> End Sub
>>
>> This is the error message I'm getting.
>>
>> 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.
>>
>> Source Error:
>>
>> Line 6:          FormView1.ChangeMode(FormViewMode.Insert)
>> Line 7:          Dim datetb As TextBox =
>> FormView1.FindControl("DateTextBox")
>> Line 8:          datetb.Text = Now.Date.ToShortDateString()
>> Line 9:      End Sub
>> Line 10: </script>
>>
>> Thanks in advance!
>> Phil
>
> Hi Phil
>
> Are there any entry in the datasource?
> 
Date:Sun, 12 Aug 2007 11:09:39 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us