Published:
29 Sep 2003
|
Abstract
The DataGrid has paging, sorting, editing, deleting, and adding capabilities, but code has to be written to make them work. My code sample is a solution to this, because it has these sub-routines already made. |
|
by Andrew Mooney
Feedback
|
Average Rating:
Views (Total / Last 10 Days):
7195/
22
|
|
|
|
[ Download Code ] | [ Run Sample ]
During my time as a database programmer I have developed many useful tools and this is the latest. The DataGrid has built-in capabilities to page, sort, edit, delete, and add, but code has to be written to make them work. This code sample is a solution to this, because it has page, sort, edit, delete, and add sub-routines already made. Using a DataGrid in one web page to make a DataGrid for another web page, allows for quick and easy creation of web pages that display information from tables in a database.
Using OleDb for connecting to databases adds versatility to this tool by allowing you to use the same code with different database types. The add routine simply adds a blank record to the database and then re-binds the DataGrid. Then the new record is moved to edit mode, where the data for the record can be entered and saved.
Known Limitations:
- You must use OLEDB connection strings:
PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\db\database.mdb; PROVIDER=SQLOLEDB; Data Source=(local); Initial Catalog=database;User ID=sa;Password=;
- Only tested with Access 2000 and SQL Server 2000.
- Does not support all data types, but should work with:
String ( 129, 130, 200, 201, 202, 203 ) Numeric ( 2, 3, 4, 5, 6, 17, 20, 131 ) Date/Time ( 7, 135 ) Boolean ( 11 )
- Each table must have an Identity or AutoNumber field as the single primary key.
- Other than the single primary key, non-updateable fields are not supported.
- To use Allow Add you must also Check Allow Edit.
- If you check Allow Edit you must check at least one column to be edited.
- You must select at least one field to be shown.
To use this sample:
- Enter an OLEDB Connection String and click Connect.
- Select a table from the drop down list and click Get Table Info.
- Select whether you want to Allow Edit, Allow Delete, or Allow Add.
- Using the checkboxes select which columns should be shown, sorted, and edited on your new page.
- Using the checkboxes select which columns should have a multiline textbox in edit mode.
- Click Create ASP.NET Page
- A textbox will appear containing the code for your new page. Copy and paste the code into your text editor and save with the .aspx extension.
|
|
|
User Comments
No comments posted yet.
|
Product Spotlight
|
|