Click here to Skip to main content
15,892,746 members
Articles / Web Development / ASP.NET

ASP.NET Web Component for editing SQL tables

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
29 Nov 2012CPOL11 min read 43K   2.5K   24  
ASP.NET c# component for editing SQL tables with plug-in column format adapter architecture.
/*
 * Code Copyright 2012 by Bill Frisbie
 * 
 * This code is licensed under COPL license.
 * Users are free to use this code, modify it and include it in other work, including works for resale.
 * Please include this notice in the code.
 * Author provides code 'as-is', and assumes no liability for any losses whatsoever arising from its use
 * Contact author at bfrisbie@optonline.net with any questions or suggestions.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BFCS.Data.Common
{
    /// <summary>
    /// Interface that must be implemented by a table adapter
    /// </summary>
    /// <remarks>
    /// This project defines a set of standard TableAdapter descended objects that implement this interface
    /// The interface defines methods for generating System.Web.Control objects for insertion into
    /// an <see>EditTable</see> table cell. The <see>ColumnTableAdapter</see> method in DbValidator class
    /// returns an instance of a standard table adapter for columns of different types.
    /// 
    /// Web sites using <see>EditTable</see> can define their own classes of the <see>TableAdapter</see>
    /// descendent that implement this interface. In order for EditTable to discover and use these custom
    /// adapters, the class must be decorated with the <see>CustomTableAdapterAttribute</see> attribute.
    /// This attribute requires that a table name and column name be declared, identifying which column
    /// the custom adapter applies to. Optionally, a string Modifiers can be declared. The string's usage
    /// is up to the implementation of the custom adapter. Typical uses are to define min/max values,
    /// to declare a table or view to be used as the source of a dropdown list, or to define the list's values
    /// explicitly.
    /// </remarks>
    public interface ITableAdapter
    {
        /// <summary>
        /// Given a value retrieved from a data source, return a System.Web.Control to display it
        /// in a non-edit, non-append row
        /// </summary>
        /// <param name="value">retrieved value</param>
        /// <returns>Control to use</returns>
        Control DisplayValue(object value);
        /// <summary>
        /// Given a value retrieved from a data source, return a System.Web.Control to display it
        /// in an edit row
        /// </summary>
        /// <param name="value">retrieved value</param>
        /// <returns>Control to use</returns>
        Control EditValue(object value);
        /// <summary>
        /// Given a value retrieved from a data source, return a System.Web.Control to display it
        /// in an edit or append row
        /// </summary>
        /// <param name="value">retrieved value</param>
        /// <param name="Appending">flag: if true, append row; otherwise, edit row</param>
        /// <returns>Control to use</returns>
        Control EditValue(object value, bool Appending);
        /// <summary>
        /// Given a value entered as a string, check for validity, modify as necessary to use
        /// in an action SQL statement
        /// </summary>
        /// <param name="setting">entered setting</param>
        /// <param name="error">(out) string representing error, if any</param>
        /// <returns>(possibly modified) string (no delimiters)</returns>
        string SaveValue(string setting, out string error);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Rovenet, Inc.
United States United States
Bill, who thinks of himself in the third person, has been programming since the dawn of time (1974) in a wide variety of hardware environments (dipswitch settings and paper tape in the beginning), languages (asm, forth, c, c++, c#, basic [visual and unvisualizable]) and industries (graphic arts, medical technology, commercial, website, mobile devices). Corporate clients include DHL, Pitney-Bowes and now-defunct medical equipment midget Q-Med. In his free time, which is all the time, he plays bluegrass guitar, body-boards the oceans of the world and bicycles through Southern California and eastern Long Island, NY.

Comments and Discussions