Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DetailsView ItemUpdating woes...

Reply
Thread Tools

DetailsView ItemUpdating woes...

 
 
Timothy H. Schilbach
Guest
Posts: n/a
 
      10-25-2006
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
################################################## ###############
<aspetailsView 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>

</aspetailsView>


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.DetailsViewUpdateEventAr gs) 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


 
Reply With Quote
 
 
 
 
Timothy H. Schilbach
Guest
Posts: n/a
 
      10-25-2006
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" <(E-Mail Removed)> wrote in message
news:%232le4YF%(E-Mail Removed)...
> 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
> ################################################## ###############
> <aspetailsView 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>
>
> </aspetailsView>
>
>
> 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.DetailsViewUpdateEventAr gs) 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
>



 
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
Formview itemupdating not updating textbox value Nic ASP .Net 0 09-11-2009 02:24 PM
ListView ItemUpdating OldValues and NewValues collections Empty (linqDataSource) Marius Manolea ASP .Net 0 06-04-2008 04:40 PM
FormView ItemUpdating event and empty NewValues... Łukasz Ledóchowski ASP .Net 0 01-01-2008 10:45 PM
Null Values in ItemUpdating Event =?Utf-8?B?Y2xpY2tvbg==?= ASP .Net 3 05-25-2006 02:49 PM
ItemUpdating using DataSource(FormView or DetailsView) =?Utf-8?B?Y2lzY28=?= ASP .Net 1 05-23-2006 10:29 AM



Advertisments