The syntax for doing so is: Protected Sub GVSupport Info_Row Updating(sender As Object, e As System. I have created a gridview that is dynamic and binds the grid dynamically based on a table selected in a dropdown.Binding form controls is mostly a simple matter of attaching a Data Source and setting your controls to reference the correct field in the Data Source. Binding a Grid View control can sometimes get tricky when using the Visual Studio editor, especially when working with Drop Down List controls within the grid. I have worked through most of the issues like dynamically creating the update, delete statements etc except for one problem I'm having in retrieving the cell value while in the rowupdating event. To String() is always an error so I am unable to get the value to plug into the dynamic update statement. ") End If End Try Row Updating Dim row Index As Integer = e. Rows(row Index) sql = sql & 'Field A' sql = sql & "=" & Grid View1. C If there is no other way; I suppose I could define the fields dynamically and use the findcontrol to obtain the value during update mode; but I've not had any success dynamically defining the field names or labels.I can retrieve it every where else; but not in this event. Cxt is always empty if your on the row being updated. If you on a different row; no problem it will return the value. egrated Security=SSPI; Initial Catalog=Test") connection. Open() Dim command2 As Sql Command = New Sql Command("Select * from Keys where Table Name='" & "Country_Table" & "'") Dim reader As Data. Sql Data Read & "] " End If Try Catch exc As Exception End Try begin = 1 End While sql = sql & " as ID, * from " & "Country_Table" reader. Data Bind() Catch ex As Exception Throw ex Finally If Grid View1. Thanks I actually haven't put it in a page load event since ultimately the work flow will require the selection of a table ; currently I have the grid bind in a button like below.--------------------------xt x = 1 i = i 1 Try ' Dim newvalue As String = e. How do I get the old values in a gridview row in the row_updating event? But it doesn't work for index items greater than 0. Must be non-negative and less than the size of the collection.
Row Updating Dim select Row As Grid View Row = Grid View Wn. I'm using a sqldatasource control to populate the grid and want to write the update code in the Row Updating event. I can get the value of the first field using string old_Category = e. To String(); it returns an error message Index was out of range. ID="Grid View1" runat="server" Auto Generate Columns="False" Data Source ID="Sql Data Source1" Border Width="0px" Border Style="None" Width="100%" Cell Padding="2" Page Size="25" On Row Deleting="Project List Grid View_Row Deleting" onrowdatabound="Grid View1_Row Data Bound" onrowupdating="Grid View1_Row Updating" onrowediting="Grid View1_Row Editing" ID="Drop Down List1" runat="server" Data Source ID="sds Ddl Projects Edit" Data Text Field="Project Name" Data Value Field="Project ID" Auto Post Back="True" onselectedindexchanged="Drop Down List1_Selected Index Changed" " Select Command="SELECT @Week Ending Week Ending , Project , Project ID , Category , Category ID ,isnull(, 0) Sun ,isnull(, 0) Mon ,isnull(, 0) Tue ,isnull(, 0) Wed ,isnull(, 0) Thu ,isnull(, 0) Fri ,isnull(, 0) Sat from (select P. I just need to get it working with the "real" one from the gridview row Sql Data Source Locations. Add("Location Name Update", Type Code.[String], "dd") Dim select Row As Grid View Row = Grid View Locations. New Values("Location ID"); ok the the update worked when I assign a mock value..