Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Newsletter
Enter your email address to receive full length articles at Stardeveloper:


Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (11)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)

Main Category  Other
  Website Maintenance (3)
Log In
UserName Or Email:

Password:

Auto-Login:

Hosted by Securewebs.com
 
Home : .NET : ADO.NET : Viewing/Adding/Editing/Removing Records from MySQL using ASP.NET DataGrid control
 
Read full length articles at Stardeveloper using Twitter Follow on Twitter Facebook Facebook fan page Email Get Articles via Email RSS Get Articles via RSS Feed

Viewing/Adding/Editing/Removing Records from MySQL using ASP.NET DataGrid control

by Faisal Khan.

Overview
In the previous tutorial (Accessing MySQL Database with ASP.NET), we learned how to obtain, install, configure and run MySQL on Windows. Later we learned how to create new tables and display records using ASP.NET DataGrid control.

Note: For the code presented in this tutorial to work, you must follow the previous tutorial to setup MySQL database server and 'Names' table.

In this tutorial we'll learn how to display, insert, edit and delete records from MySQL database using the same ASP.NET DataGrid control on a single ASP.NET page. We'll also learn how to validate user input using ASP.NET Validation controls.

Once you go through this tutorial, you'd have learned enough about ASP.NET DataGrid control that'll make displaying, inserting, editing and deleting records from MySQL, a breeze.

How will the finished ASP.NET page look like?
Before delving into the code, let me first show you how the page will look like when first viewed from the browser and how the add, edit and delete forms will look like.

  1. ASP.NET page displaying all records

    If you followed the previous tutorial you'll know that 'Names' table in the 'test' database of MySQL, contained 6 rows of first and last names. This is how those names will look like when first viewed from the ASP.NET page:

    Viewing all records in the 'Names' table
    Viewing all records in the 'Names' table


  2. Adding new record

    We can use the form to add new first and last name pair. This is how it looks like when we type in the new name:

    Adding new name
    Adding new name


    And this is how it looks when we click the 'Add' link:

    New name visible in the 'Names' table
    New name visible in the 'Names' table


    Our new name is shown at the bottom of 'Names' table.

  3. Editing a record

    What if you are jealous to see my name (Faisal Khan) among the top guys and want to change it to your name? Well this is also easy. Just have a look at the following form to see what happens when the 'Edit' link at the side of the name 'Faisal Khan' is clicked:

    Editing the name 'Faisal Khan'
    Editing the name 'Faisal Khan'


    We edit the name to 'Your Name':

    Changing to 'Your Name'
    Changing to 'Your Name'


    Clicking the 'Update' link will change 'Faisal Khan' to 'Your Name' as shown below:

    Changing to 'Your Name'
    Changing to 'Your Name'


  4. Deleting a record

    What if you are an honest guy and think that neither 'Faisal Khan' nor 'Your Name' belong in table containing names of top technology entrepreneurs. So this is how it'll look when you click the 'Delete' link at the side of 'Your Name':

    Deleting 'Your Name'
    Deleting 'Your Name'


    'Your Name' has been removed from the 'Names' table.

 ( 10 Remaining ) Next

Comments/Questions ( Threads: 22, Comments: 34 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. need badly same tutorial for CRUD Datalist for .net,c# and mysql
  2. SQL Server ( 1 Reply )
  3. DataGrid can not be updated am using asp.net
  4. VB.Net Source
  5. CS1501: No overload for method 'DoUpdateName' takes '12' arguments
  6. Updating data in datagrid in asp.net
  7. How to write Stored Procedures in MySql for insertion, Updation....
  8. System.FormatException ( 1 Reply )
  9. tutorial? ( 3 Replies ) This thread contains 2 replies by the Author of this Article. This thread contains 2 replies by Faisal Khan.
  10. how to add references to aspx page
  11. Redundant data
  12. ni8ce
  13. Error
  14. mysql autonumber ( 1 Reply )
  15. SQL vs MySQL ( 3 Replies )
  16. Compilation Error
  17. Compilation Error ( 2 Replies )
  18. accessing Mysql without datagrid? ( 1 Reply )
  19. Just what I was looking for!
  20. Hi

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed.

 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.