PC Review


Reply
Thread Tools Rate Thread

can't reference textbox inside details view

 
 
Bobby Edward
Guest
Posts: n/a
 
      6th Mar 2008
What am I doing wrong?

When it gets to the "MyTextBox.Text = Now" line I get "Object reference not
set to an instance of an object."

PARTIAL HTML:
<aspetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
CellPadding="4" DataKeyNames="ID" DataSourceID="adsObitDetails"
ForeColor="#333333"
GridLines="None" Height="50px" Width="100%">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<Fields>
:
<asp:TemplateField HeaderText="Entered"
SortExpression="InputDateTime">
<EditItemTemplate>
<asp:TextBox ID="txtInputDateTime" runat="server"
Text='<%# Bind("InputDateTime") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="txtInputDateTime" runat="server"
Text='<%# Bind("InputDateTime") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("InputDateTime") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
:
</Fields>
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</aspetailsView>

CODE:
Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles
DetailsView1.ModeChanging
If e.NewMode = DetailsViewMode.Insert Then
Dim MyTextBox As TextBox
MyTextBox =
CType(Me.DetailsView1.FindControl("txtInputDateTime"), TextBox)
MyTextBox.Text = Now
End If
End Sub


 
Reply With Quote
 
 
 
 
Teresita Núñez - SorCereSs -
Guest
Posts: n/a
 
      6th Mar 2008
Hi,
just guessing, are you trying to write the current datetime at the textbox
MyTextBox?
in that case, did you try...
MyTextBox.Tex = DateTime.Now.ToString()

The error you're getting it's because it assumes that Now is a variable and
tries to find it to take its value.

--

SorCereSs
MCTS: NET Framework 2.0 - Web-Based Client Development
MCPD: Web Developer
Microsoft Student Partner - Paraguay

 
Reply With Quote
 
Bobby Edward
Guest
Posts: n/a
 
      6th Mar 2008
Thanks. I'll give that a try...

"Teresita Núñez - SorCereSs - " <(E-Mail Removed)> wrote in message
news:4CEBC400-F460-4EA7-B3BA-(E-Mail Removed)...
> Hi,
> just guessing, are you trying to write the current datetime at the textbox
> MyTextBox?
> in that case, did you try...
> MyTextBox.Tex = DateTime.Now.ToString()
>
> The error you're getting it's because it assumes that Now is a variable
> and tries to find it to take its value.
>
> --
>
> SorCereSs
> MCTS: NET Framework 2.0 - Web-Based Client Development
> MCPD: Web Developer
> Microsoft Student Partner - Paraguay



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
I'm not sure what to call it (details inside) Moe- Microsoft Word Document Management 1 28th Sep 2008 05:29 PM
No Folder Size in Details Pane or Details View ?! Synapse Syndrome Windows Vista General Discussion 17 26th Nov 2007 08:02 AM
Details List / Choose details to View Len Windows XP General 6 15th Nov 2004 01:39 PM
Details view--Choose Details--Pages displays incorrect data Jaci Smeltzer Windows XP Basics 1 27th Aug 2004 06:22 AM
VB.NET Error .... details explained inside. HELP!!! D P Microsoft VB .NET 4 20th May 2004 03:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:49 AM.