Rowupdating event in gridview in asp net
you can always just turn the boundfield into a template field then put whatever control you want in templatefield then bind that control to any datasource you'd like (once again I prefer linq over all of the rest).
This is not necessarily a bad thing, we can still get all the functionality you can get from going from the codebehind. ♦ I prefer to use linq, but the fact is that when your using controls like the Grid View or Detials View etc..
Append("SELECT Project ID, Pcb Pn, Pcb Pn Rev, Change Number, Design Names, ECADdesigner Names, Pwb Engineer Names, Pwb Request Date, ECADstart Date, Due Date, Project Status, Job Charge Number, Percent Complete, Completion Date, Actual Start Date, Schematic Number, Schem Num Revision, Schem Ready Date, Layer Count, PCBtechnology, Stack Up, Thickness, Lead Free, Requester Comments, Product Manager") str SQL. Append(" WHERE" & str Params & " ORDER BY Due Date ASC") 'This is a subtitute for Private Sub Populate Publishers Grid View() from example code 'found at View Sorting Dim str My Conn As String = Configuration Manager.
Text & "')" End If End If 'WHY NOT USE Drop Down List4. I have a dynamically created gridview, it's autogeneratedcolumns is set to True, and it databinds on every postback. If i move the databind to load (which fires before the Row Updating) it ceases to work correctly, and the newvalues are null. Dim o Conn as new Sql Connection("") Dim o Cmd as new Sql Command("Update Sp", o Conn) o Cmd. Guys maybe it's just Friday evening and I've already had 1 Guinness to ease the tension, but you two just flew about 30,000 feet over my head. Crack open reflector and look at the Grid View's source code. The event arguments will ALWAYS be empty unless you are bound to a datasource control. created the following code in VB, and though it runs without error, it's not doing anything for me. This is such a monumental show stopper after all the work I have put into this web site, I can't believe there isn't a straight forward method of retrieving the new values. Edit Index) Dim dict Values As New Ordered Dictionary Dim o Ctl As Control For Each o Ctl In gv Row. Row State, False) End If Next Dim dict Entry As Dictionary Entry For Each dict Entry In dict Values Try Msg Box(dict Entry. To String) Catch ex As Exception End Try Next Public Shared Function Get Values(row As Grid View Row) As IDictionary (Of String, Object ) Dim values = New Ordered Dictionary() For Each control As Control In row. Unfortunately I am getting identical results...same I have always been getting which is just the old values. Try to write a small sample with one column and that one event and see if it works. 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. 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? 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(! 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. Protected Sub Page_Load(By Val sender As Object, By Val e As System. Load Dim i Col As Integer, c As Integer = 0, i Chx As Integer 'If In Str(Http Context. Selected = True Else End If Fill Grid View() End Sub Private Sub Fill Grid View() Dim i Col As Integer, c As Integer = 0, i Chx As Integer, i As Integer Dim str SQL As New System. String Builder Dim str Params As String = "" 'THE FOLLOWING CODE THAT INDICATES SPECIFIC COLUMN NUMBERS IS DETERMINED 'BY THE HTML ASPX CODE THAT DETERMINES HOW THE GRIDVIEW LOOKS For i Chx = 0 To Me.