Updating gridview rows using sqldatasource
Hi, I am looking for a way to update a column of gridview fields based on the value of the first column, basically an auto-fill.I am able to get the value of the field I need however, I am not able to update the fields beneath the first row.The Textbox values come back as empty, which is even stranger. Below is the code for both the Grid View HTML and the C# code behind.Code (C# On Updating Event) protected void gv Main_Row Updating(object sender, Grid View Update Event Args e) Gridview HTML Code x WHERE (Rec ID = @Rec ID) " Select Command="SELECT Rec ID, Company ID, Region ID, Country ID, Company Code, Company Name, App ID, Country Code, Country Name, Region Company ID, Region, Model Name, Translate Model, Price, Last Updated On, Last Updated By FROM dbo.
ALTER PROCEDURE users_Update Faculty @EMAIL NVARCHAR(100), @ISLOCKEDOUT BIT, @MOBILENUMBER BIGINT, @USERNAME nvarchar(100) AS BEGIN UPDATE aspnet_Users SET [email protected] where [email protected] UPDATE ASPNET_MEMBERSHIP SET EMAIL = @EMAIL, LOWEREDEMAIL = LOWER(@EMAIL), [email protected] WHERE USERID = (SELECT USERID FROM ASPNET_USERS WHERE [email protected]) END Found the solution: The Select Columns and the Update Parameters should match in order to update using Sql Data Source, that means if you select(query or procedure) is returning 3 fields in gridview, then all of them should be the parameter for the update, you can miss out the actual updations in database if not required, but the I dont think your solution is OK, since I have to use the atribute Old Values Parameter Format String="original_" that means that I would have doble parameters, the ones with the original values and the ones with edited values. I have 4 parameters, Im getting the right values for 2 of them, an null at the others.
Read this: The order of the parameters in the Update Parameters collection might be important, depending on the ADO.
Odbc providers associate the parameters in the collection according to the order that the parameters appear in the parameterized SQL query.
I tried using Grid View Row to find the field and change it however it does not seem to have a method to directly update fields rather retrieve cell information.
control, you can specify SQL queries and statements that use parameters.
That is, I don't want to use the autogenerated command controls on the gridview.