Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retrieving fields with default values in ASP.NET 2.0 in Postback

Reply
Thread Tools

Retrieving fields with default values in ASP.NET 2.0 in Postback

 
 
cjbland
Guest
Posts: n/a
 
      02-24-2006
First off I apologize if this has been discussed before, I'm not
certain how to search for what I'm looking for so I figured I'd throw
this out there and see what I got.

I am working with a DetailsView (Insert mode) in ASP.NET 2.0 and one of
the fields I give a default value.

<aspetailsView ....>
<asp:TemplateField HeaderText="Date Entered"
SortExpression="d_entered">
<InsertItemTemplate>
<asp:TextBox ID="DateEntered" name="DateEntered" Text='<%# DateTime.Now
%>' ReadOnly="false" runat="server" />
</InsertItemTemplate
</asp:TemplateField>
.........
</aspetailsView>

When I click the insert button all of the values of my form are
returned except for the date entered. I viewed the source of my main
page and all of my other inputs have an id of "DetailsView1$ctl0x"
where x is a number. The ID for my date field is
"DetailsView1$DateEntered".

In my debugging I've created a few labels and I am setting them via:

protected void DetailsView1_ItemInserting(Object sender,
DetailsViewInsertEventArgs e)
{
a.Text = e.Values["serial_no"].ToString();
b.Text = e.Values["barcode"].ToString();
c.Text = e.Values["DateEntered"].ToString();
}

The page errors on the "c.Text = ..." line and it says that
"DateEntered" doesn't exist. I am obviously missing something here,
does any one have any input? Thanks in advance.

 
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
print struct fields and its member structs' fields recursively, generically call_me_anything C++ 4 09-30-2007 10:12 PM
[asp] remembering values after postback - changes values Piotrek \Alchemik\ ASP .Net 0 11-12-2006 09:18 PM
How to set default values for fields in detailsview mt ASP .Net Web Controls 1 04-10-2006 10:29 PM
retrieving user control values on postback fernandezr ASP .Net 0 03-09-2006 09:15 PM
Retrieving the x-receiver list from a CDO Message using the Fields Collection David Morgan ASP General 0 10-06-2004 11:38 AM



Advertisments