Detailsview itemupdating newvalues

File Name Catch ex As Exception File Upload Report. Message End Try End If End Sub Thanks, Rob Not sure if it helps in resolving the error, but look at this: dim x as integer = e.newvalues.count The Count property of the New Values collection has nothing to do with the number of records that the Details View is displaying. Count refers to the number of fields / columns that your object has. NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004Ok....ultimately, what I am tryign to do is take the current item being edited and put the value of a selected dropdown into the value "ptype" for the currently selected record in the detailsview. What's odd--is this works for the first 8 records--this line. Details View Update Event Ar gs) _ Handles Details View1. New Values("Title") = "New Title Here" End Sub This sets or overwrites the value of the parameter called Title. Imar --------------------------------------- Imar Spaanjaars I used the same design as Imar did on the 3-layer article and so I was able to see what values were passed into my "paintings" object and each one was passed correctly.

Selected Value) I thought that this would put the value into Ptype for the currently selected item. So, I thought that if there were 12 records in my detailsview, there would be 12 "newvalues", I thought e. Intelli Sense for New Values might have revealed that: "Gets a dictionary that contains the new field name/value pairs for the record to update" Imar --------------------------------------- Imar Spaanjaars Cheers, Imar --------------------------------------- Imar Spaanjaars I actually debugged and even though I had e.newvalues(e.commandargument, "ptype", dropdownlist1.selectedvalue) which translated to (1, "ptype", 20) where 20 is and id to a table value and 1 is the second field (0-based array) of the record which is not ptype---it still passed the right parameters into my object.

Fernando I think i am getting trapped by the fact that unless you use the Linq Data Source control 100% for binding data you will not have access to the New Values.

New Values[i], In the debugger I can see the keys but they are defined as non-public.

The post-processing in Item Updating is easy enough but the pre-processing in Data Bound is messy...

event is raised when an Update button within the Details View control is clicked, but after the update operation.

This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. At the bottom, it has them indexed by 1 2 3 4 5 6 7 8 9 10 ... Once you add the same key again using Insert, you get an error.

NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. When I try editing the 9th element on, I get the following error: (Note: the Details View obiviously has more than 8 records. Ht H, Imar --------------------------------------- Imar Spaanjaars My logic was obviously wrong for editing..would I need to change it to so that the current item being "updated" will have the selected value from the dropdown input into "ptype"--and.did it work for the first 8 items the way I have it? Rob Then when the updating event fires, you can do something like this: Protected Sub Details View1_Item Updating(By Val sender As Object, _ By Val e As System. I must assume that by "insert" all it did was reposition the "ptype" field in the got about the amount of parameters being passed--it errored. The New Values collection is an Ordered Dictionary that only allows unique keys.

Find Control("Drop Down List1"), Drop Down List)Line 34: e.

When I try editing any of the first 8 elements, I'm fine. So, a simple object with just an ID and a Description would give a Count of 2. I tried doing this via the Details View_Item Updating event as: e. Ironically enough..there are 8 fields in the Details View that are "editable" with the ptype being a dropdown in there--the 4th control in the edit view. So regardless as to whether I picked (1, "ptype", 20) or (3, "ptype", 20) or any other number in the first parameter below 8 -- it worked fine.

I did debug and put a line: dim x as integer = e.newvalues.count and it was recording 7 (or 8--i forget). I haven't seen the rest of your page so I can only guess, but my take is you're not supplying a value for ptype in the code before (e.g. Command Argument, "Title", "New Value") You'll see it crashes with an error stating that Title (or whatever column name you have) already exists.

Here is my detailsview: I tried adding a label to my page and then once updated Name had been assigned the value of the textbox I tried assigning that value to the label and it printed out the old product name not the one in the textbox.

I can't see anything wrong with the code and it's driving me mad. hi, i think you miss something, try to see the table where you save the value of the fields you entered if it change anything, if it change anything, then you have put some code on your SP that retrieves data after the UPDATE code that you have.

Leave a Reply