Detailsview itemupdating newvalues

Rated 4.83/5 based on 784 customer reviews

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.

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.

I'm using a detailsview with an sqldatasource in the aspx page.

I'm trying to do some pre and post processing on some of the fields - basically to convert a html list to a newline separated list for editing and back to html to store in the database.

Ok, Now I'm sure this was working the other day and I don't think I've changed anything but now it's not working and I can't see anything wrong with the code.

event is raised when an Update button within the Details View control is clicked, but after the update operation. Kind Regards, Rob I don't know that either as I don't know what you did. Insert takes as its first argument a zero-based index of the collection. Once you got passed record 8, you tried to insert an item beyond the length of the collection (e. NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004Makes Sense...thank you VERY much! Selected Value) You were not assigning the existing parameters a new value, but you were creating a *new* parameter using the Insert method. Insert(0, "ptype", "Some Value") would insert a new value at the very first position. Newvalues represented each record that was returned--not the fields of a record that is being updated. Remember, the Details View, while capable of displaying multiple, pageable records, only works with one record at the time. It worked while your record index was less than the number of properties / columns in your data source. Or, does it replace the existing parameter with the "new" one. Let's say my parameters were: fname = Rob mname = John lname = Searing state = KS and I do e.newvalues.insert(0, "lname", "Spaanjaars") will that replace the "fname" parameter with "lname" (because fname is the 0-placed parameter--and I am performing an insert into the "0" position with a different parameter name "lname" The reason I ask is because "ptype" was not the "0" position element in the record..filename was..the filename didn't change with e.newvalues.insert(e.commandargment, "ptype", dropdownlist.selectedvalue).fact everything worked liked I wanted it to..when I try editing the "second" record-which would have resulted in e.newvalues.insert(1, "ptype", value) or the third, which would be e.newvalues.insert(2, "ptype", value)..always updated perfectly..sure why. I am still curious about the behavior and why, what I describe above, worked. NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004I think so.. I think my biggest problem was that I thought that e. Selected Value) Where e.command Argument was the "selected record" (ie the 9th record) and that e. Insert would insert the value of the selected dropdown and put it into "ptype" for the "9th" record) Obviously, my logic was skewed..not sure why this actually worked for the first 8 records (first 8 paintings) that were returned. However, New Values contains the new values for the current record being updated, giving you a chance to modify the current data before it gets sent to the data source. NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004While reading your original post again, I see what the problem is: e. Command Argument contains the zero-based index of the *record* in the Details View). You used the record index to determine a property index. Last question--so if it was creating a new parameter--would it matter what the size of the e.newvalues was?

Leave a Reply