DetailsView ItemUpdating woes...

Discussion in 'ASP .Net' started by Timothy H. Schilbach, Oct 25, 2006.

  1. Hi Everyone,

    I am having a massive issue trying to get custom data into my DV. What I
    want to do is sooo simple:

    1. I have a single DV on a page
    2. I created my own template (see below)
    3. I created the DetailsViewDataBinging sub which populates the field using
    a datatable
    4. I created a ModeChanging Event handler to allow me to change the mode
    into EDIT mode
    5. I created a ItemUpdating mode to handle the item update.

    No matter what I do or what I put in, the e.NewValues or e.OldValue
    contain NOTHING... Whan I do a count I see 0 everytime. Non of my fields are
    Template fields and they are all databound. Everything works with any
    issues, just no data is ever returned.

    I hope these shed some light:

    DETAILSVIEW1
    #################################################################
    <asp:DetailsView ID="DetailsView1" runat="server" Width="125px"
    AutoGenerateRows="False">

    <Fields>

    <asp:BoundField DataField="FirstName" HeaderText="First Name:" />

    <asp:BoundField DataField="LastName" HeaderText="Last Name:" />

    <asp:BoundField DataField="DisplayName" HeaderText="Display Name:" />

    <asp:BoundField DataField="Description" HeaderText="Description:" />

    <asp:BoundField DataField="PrimaryEmail" HeaderText="Primary Email:"
    ReadOnly="True" />

    <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />

    </Fields>

    </asp:DetailsView>


    Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles
    DetailsView1.ModeChanging

    '# When the form mode changes we handle how the form loads and what it looks
    like here

    Select Case e.NewMode

    'Put into edit mode and databind

    Case DetailsViewMode.Edit

    DetailsView1.ChangeMode(DetailsViewMode.Edit)

    'BindDetailsView()

    'Put into insert mode

    Case DetailsViewMode.Insert

    'put into read only mode and databind

    Case DetailsViewMode.ReadOnly

    DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)

    BindDetailsView()

    End Select

    End Sub

    Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
    DetailsView1.ItemUpdating
    Response.Write(e.NewValues.Count)

    End Sub

    What Else am I missing here? This is driving me batty as I cannotdo anything
    with my data. All I want to do is intercept the NewValues and put them in my
    custom data solution.

    -Timothy
    Timothy H. Schilbach, Oct 25, 2006
    #1
    1. Advertising

  2. UPDATE:

    Ok I dont know why this is, but maybe someone can explain it to me.

    My custom data routine that I was using to bind data to my DetailsView was
    comming from the active directory. I had created all of the databindings and
    everything was working very well. But I could not delete or update any data
    as it would tell me there were no fields upon the post back in the
    ItemDeleting or ItemUpdating event handlers.

    As an experiment I have created an ODS (ObjectDataSource) that has custome
    select and custom UPdate routines. I create a USER and EMAILUSER class and
    populated them with their corresponding attributes. I was then able to go
    back to my test page and drop an ODS connector on there and attach to the
    custom select and update routines. I bound that to the DetailsView and low
    and behold it works! It now returns the correct number of fields.

    Why is it when I use my own DataBinding routines (which bind to the data
    just fine) in a code behind page that I have issues when it comes to the
    ItemDelting or ItemUpdating routines?

    I hate the idea with beign stuck with an ODS as its less efficient now I
    have to make 2 calls to my active directory to accomplish the same thing I
    was able to do with a single call and some rather complex logic (like adding
    and subtracting email address aliases to exchange). While an ODS may be nice
    for those afraid of code, I prefer to do my complex operations the old
    school way in the code behind page.

    Can anyone shed any light on this?

    -Timothy



    "Timothy H. Schilbach" <> wrote in message
    news:%232le4YF%...
    > Hi Everyone,
    >
    > I am having a massive issue trying to get custom data into my DV. What I
    > want to do is sooo simple:
    >
    > 1. I have a single DV on a page
    > 2. I created my own template (see below)
    > 3. I created the DetailsViewDataBinging sub which populates the field
    > using a datatable
    > 4. I created a ModeChanging Event handler to allow me to change the mode
    > into EDIT mode
    > 5. I created a ItemUpdating mode to handle the item update.
    >
    > No matter what I do or what I put in, the e.NewValues or e.OldValue
    > contain NOTHING... Whan I do a count I see 0 everytime. Non of my fields
    > are Template fields and they are all databound. Everything works with any
    > issues, just no data is ever returned.
    >
    > I hope these shed some light:
    >
    > DETAILSVIEW1
    > #################################################################
    > <asp:DetailsView ID="DetailsView1" runat="server" Width="125px"
    > AutoGenerateRows="False">
    >
    > <Fields>
    >
    > <asp:BoundField DataField="FirstName" HeaderText="First Name:" />
    >
    > <asp:BoundField DataField="LastName" HeaderText="Last Name:" />
    >
    > <asp:BoundField DataField="DisplayName" HeaderText="Display Name:" />
    >
    > <asp:BoundField DataField="Description" HeaderText="Description:" />
    >
    > <asp:BoundField DataField="PrimaryEmail" HeaderText="Primary Email:"
    > ReadOnly="True" />
    >
    > <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
    >
    > </Fields>
    >
    > </asp:DetailsView>
    >
    >
    > Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles
    > DetailsView1.ModeChanging
    >
    > '# When the form mode changes we handle how the form loads and what it
    > looks like here
    >
    > Select Case e.NewMode
    >
    > 'Put into edit mode and databind
    >
    > Case DetailsViewMode.Edit
    >
    > DetailsView1.ChangeMode(DetailsViewMode.Edit)
    >
    > 'BindDetailsView()
    >
    > 'Put into insert mode
    >
    > Case DetailsViewMode.Insert
    >
    > 'put into read only mode and databind
    >
    > Case DetailsViewMode.ReadOnly
    >
    > DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    >
    > BindDetailsView()
    >
    > End Select
    >
    > End Sub
    >
    > Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
    > DetailsView1.ItemUpdating
    > Response.Write(e.NewValues.Count)
    >
    > End Sub
    >
    > What Else am I missing here? This is driving me batty as I cannotdo
    > anything with my data. All I want to do is intercept the NewValues and put
    > them in my custom data solution.
    >
    > -Timothy
    >
    Timothy H. Schilbach, Oct 25, 2006
    #2
    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. =?Utf-8?B?Y2lzY28=?=

    ItemUpdating using DataSource(FormView or DetailsView)

    =?Utf-8?B?Y2lzY28=?=, May 22, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,768
    Walter Wang [MSFT]
    May 23, 2006
  2. =?Utf-8?B?Y2xpY2tvbg==?=

    Null Values in ItemUpdating Event

    =?Utf-8?B?Y2xpY2tvbg==?=, May 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    4,285
    =?Utf-8?B?Y2xpY2tvbg==?=
    May 25, 2006
  3. £ukasz Ledóchowski

    FormView ItemUpdating event and empty NewValues...

    £ukasz Ledóchowski, Jan 1, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    859
    £ukasz Ledóchowski
    Jan 1, 2008
  4. Marius Manolea
    Replies:
    0
    Views:
    1,010
    Marius Manolea
    Jun 4, 2008
  5. Nic
    Replies:
    0
    Views:
    1,480
Loading...

Share This Page