Update gridview row rowupdating event in asp net
For those who stumble across this post later on, the only thing I had to change in the code above was (gvr. Find Control("txt Object Class") - a simple spelling error. I appreciate you putting in all that time and energy to help me out.The textbox is visible when the gridview is in "edit mode", and the label is visible when the gridview is in "normal mode" 2) When I place a breakpoint in the rowupdating method, it looks like the values are changed as I would expect them to be. Update() End Sub Thanks, Qin, Thanks for the response. But when the Gridview displays, the "1111" isn't there - but the changes made by the user are! Hi juriggs, If the textbox and label are bound to data source, you needn't to set the text manually. You were right, I am binding the Grid View with a Sql Data Source. before that i want just using Find control and casting and then retrieving all lot code. If values are same they could notify user to change the value(give new cell value). Every one can use it to compare the new value with old ones.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.
So the problem I am having is that when I get the Datakey value I am trying to get the values in the controls in the Edit Mode of the current row I am trying to update. I am using the Find Control function to get the values from the editing row so I specifically name the dropdownlists and textboxes so I can access them here.For example, when the program executes: Sql Data Source1. Default Value = Direct Cast \ shortened for brevity my Autos Pane shows: Sql Data Source1. Default Value = "cheeseburgers1111" as the Value for the Parameter (with "cheeseburgers" being what I typed into the gridview cell). Also, I realized that the Grid View is inside of an Update Panel. In other words, if the user types in "cheeseburger", that is what shows in the updated Gridview. But when the gridview binds, the cell's text (lbl Description) just reads "cheeseburger". What I'm looking for is "cheeseburger1111" to show in the updated Gridview. But what happens is that I do get some of the values but they are the original values not the new ones being changed.In the code below I do get the Country ID and Region ID but they are the original values not the new ones selectedfrom the Edit Mode row.