Getting the new value in gridview rowupdating men thinking about online dating beware
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. i am getting old values in the rowupdation in gridview , while clicking over the update button , in my code behind i am using below code to get value. Find Control("txtunit_price") 'Reset the edit index. To get both the old and the new value of a field named unit_price, (for the example as a String. Find Control("txtdescription") Dim txtunit_price As Text Box = gvr. Edit Index = -1 'Bind data to the Grid View control. When all you've got is a Hammer, Every Problem looks like a Nail. Since you are already getting a Row Updating event, I'll work from there. Text "" Then str Params = "(" & str Params & ") AND (ECADdesigner Names ='" & Me. Text & "')" End If End If 'WHY NOT USE Drop Down List4.
This can be beneficial to other community members reading the thread. 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 believe that databinding on every postback is the cause but that's not something that I can change right now, same goes with the autogeneratedcolumns setting. I'm not sure if I know what you mean about 2 way binding. If you meanam I using Bind instead of Eval in my HTML, then yes. And the result of your code is no different than my version or what I was doing before, which was just using the findcontrol method, and that just returns what was in the grid when it was first binded to the database on page load. Yes ok i think i know what you are probably doing wrong. I'd like to know if there are any other ways to retrieve the new values? I have been using the web site successfully for just over a year, and I am presently using a Select button in the row to launch a detailsview, and I edit the database that way. Net a year and a half ago, and VB programmer forever before that, but I feel pretty confident in this large and powerful website I have created, but the users don't like the details view have expressed a desire to edit on the fly in the gridview. My user base has a hold of management's ear, and my management wants to dump ASP. This could be the straw that broke the camel's back - a person's job hangs in the balance - MINE!! If you are databinding in page_load then you need to only do it if(!