Retrieving dropdownlist gridview rowupdating event accommodating individuals with
There must be something fundamentally wrong that some of us are doing that is causing this and the fact that it's not happening to others, and they don't know the solution. this only works when the databind happends after the updating. My suggestion to you would be to either subclass gridview, and expose the Extract Row Values though a public method or stick everything you need in Data Keynames. Extract Values From Cell(dict Values, dcfc Cell, gv Row. Row State, True) End If Next control Dim return Values = New Dictionary (Of String, Object )() For Each de As Dictionary Entry In values return Values(CStr(de. Value Next de Return return Values End Function I appreciate your quick and prompt reply, which I looked at from home last night, but was not able to test it until just now, and really the only different was adding the Try Cast. You're trying to extract the values from the edit row right? It'd be great if you could provide some sample code here. I am using the Row Updating event to programmatically update my database, but the new values are already gone by the time the Row Updating event is fired. I have found several forum postings detailing this but no one has posted their solution. Another way to get values out of the gridview is to put the interesting fields in Data Key Names, which can be a very ugly solution because the viewstate grows as a result of this. I've attached my code for what it's worth, but it will probably be too dificult to determine everything that I am doing. Is there a flag I can turn on or off when I am doing row updating so that I can detect and not rebind? Visible = True Catch ex As Exception Track Projects. Close() End Using Hi Lite Rows() End Sub Private Sub Hi Lite Rows() 'THE FOLLOWING CODE THAT INDICATES SPECIFIC COLUMN NUMBERS IS DETERMINED 'BY THE HTML ASPX CODE THAT DETERMINES HOW THE GRIDVIEW LOOKS Dim i Col Date As Integer = 7, i Row As Integer, i Col Proj Stat As Integer = 9 ' Msg Box(Track Projects.
Now, when an user edit a row then click update, I'm having problem getting the new values in gridview's rowupdating event, it always returns the old values. With that being said you could go directly after the form post data perhaps, i usually find it's easiest to debug then search through and find your key value pair. I'll take a closer look at your posts maybe tomorrow, and definitely Monday, but I'm just a hack, and I so close to dumping this whole thing and lettting someone else do it...whooops there isn't anyone else... The new values are not being retrieved, just the old values. Excuse my crude Msg Box methos; it only goes to prove what a hack I am. Controls Dim dcfc Cell As Data Control Field Cell = o Ctl If dcfc Cell Is DBNull. Controls Dim cell As Data Control Field Cell = Try Cast(control, Data Control Field Cell) If cell Is Not Nothing And Also cell. By the way, when I attempted to cut and paste your code, the compiler would not accept the arguments (String, Object) at the end of IDictionary, saying that IDictionary has no parameters, and also in the return values portion below it complains that Dictionary is not a type. Dictionary is a generic type and you have to include System. I'm not sure whats going on in your case Yes I am getting the exact data that's in the edit row. It's a record that looks similar to the other data in the database, but it is defintiely different values so I am confident that I am looking at the edit row.
Data Bind() End Sub Its not your fault that the new values are empty.
Is Post Back) otherwise you'll wipe out the new values everytime before the updating event gets called.
I know its very annoying and hard to get the data out of the data controls (gridview in this case), but there are other things you can do to make it easier.
The reason is we don't fill the values unless your are bound to a datasource control.