Gridview rowupdating event code
NET 2.0 Grid View control to view, add, update, and delete data in a SQL database. In this code below code, you see database table columns binding with the bound fields and formatting is provided using the template fields.
The below is my connection string which is stored in web.config file. If you are using my database, just copy and paste the code or use the attached application.
NET page that will handle different Grid View events to provide complete editing functionality.
In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: For brevity I am not storing connection string in the web.config and also not using any Data Access Component.
Here in Grid View, in the beginning the major part is to make the decision of putting either a bound field or a template field and the answer is simple: When we want to place any control inside the Grid View then we can go for template field, otherwise bound field will be simpler.
Now I will show you the C# code behind file of the above ASP.
You can change this connection string according to your SQL server database setting. If you want use my database file then attach that file. If you are using your database, you need to replace column binding with your database table columns.
This function is use to fetch data from the Vendor table, fills data in a Data Table object and find it to a Grid View control using the Data Source property. For more information I am attaching my test application and database, so download it for better result and if you liked this article or you have any advice about my any article don't be hesitate drop me a comment on c-sharpcorner comment section.
Free counters Added on January 19,2012 Follow Me @vmsdurano A bit About Me Disclaimer The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers.
Nor does it represent the opinion of my dog, because I don’t have one.