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

Discussion in 'ASP .Net' started by cjbland, Feb 24, 2006.

  1. cjbland

    cjbland Guest

    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.

    <asp:DetailsView ....>
    <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>
    .........
    </asp:DetailsView>

    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.
    cjbland, Feb 24, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fernandezr
    Replies:
    0
    Views:
    556
    fernandezr
    Mar 9, 2006
  2. Piotrek \Alchemik\
    Replies:
    0
    Views:
    300
    Piotrek \Alchemik\
    Nov 12, 2006
  3. Susan Harris
    Replies:
    1
    Views:
    734
    Karl-Inge Reknes
    Jan 11, 2009
  4. mt
    Replies:
    1
    Views:
    298
    Phillip Williams
    Apr 10, 2006
  5. David Morgan
    Replies:
    0
    Views:
    356
    David Morgan
    Oct 6, 2004
Loading...

Share This Page