Gridview edit mode rowupdating
After filling the Grid View click on the Grid View; click EDIT Column convert to field to convert this field into a Template Field.In this article I explained it using Bound Field In my Next Article I will show How to Edit Update Grid View Using Template Field.If he clicks edit (or) in the edit mode he can be able to see the Textbox.The above piece of code will also do the same as label in Item Template and Textbox in the Edit Item Template.Protected Sub Grid View1_Row Data Bound(By Val sender As Object, By Val e As Grid View Row Event Args) Dim d Row View As Data Row View = Direct Cast(e. Edit) 0 Then Dim rbl Gender As Radio Button List = Direct Cast(e. Find Control("rb Gender Edit"), Radio Button List) Dim ddl Status As Drop Down List = Direct Cast(e. Find Control("ddl Status Edit"), Drop Down List) rbl Gender. In case of the bound field’s we need to check what column it is and need to use index of that cloumn, which is little hard and even in future if we change the column order If you see the Last Template Field part in the above code, I am using the link buttons for edit, update, delete and cancel.
So am calling the method Bind Grid Data method which is overloaded .
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.
Scenario: I am using the Row Updating Event of the Gridview to do updates because I need more flexibility than the SQLDatasource Update provides.
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.