Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why this error message?

Reply
Thread Tools

Why this error message?

 
 
pvong
Guest
Posts: n/a
 
      08-12-2007
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


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      08-12-2007
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?

 
Reply With Quote
 
 
 
 
pvong
Guest
Posts: n/a
 
      08-12-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Cisco 2611 and Cisco 1721 : Why , why , why ????? sam@nospam.org Cisco 10 05-01-2005 08:49 AM
Why, why, why??? =?Utf-8?B?VGltOjouLg==?= ASP .Net 6 01-27-2005 03:35 PM
Why Why Why You HAVE NO IDEA MCSE 31 04-24-2004 06:40 PM



Advertisments