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

Creating a web control to insert, update, delete, and display data

Rate me:
Please Sign up or sign in to vote.
4.35/5 (11 votes)
12 Apr 2006CPOL7 min read 69K   1.2K   60  
Creating a web control to insert, update, delete, and display data.
using System;
using System.Web.UI.WebControls;
using System.Web.UI;

/* Copyright � 2006 Luis Enrique Ramirez Figueroa. All rights reserved. */

namespace DataCatalogNamespace
{
	public class CommandItem : TableRow, INamingContainer
	{
		public CommandItem()
		{
		}

		protected override void CreateChildControls()
		{
			TableCell cell = new TableCell();
			this.Cells.Add(cell);

			cell.ColumnSpan = 2;

			Button button = new Button();				
			cell.Controls.Add(button);
			button.CommandName = "Insert";
			button.Text = "Insert";
			LiteralControl space = new LiteralControl(" ");
			cell.Controls.Add(space);
			
			button = new Button();				
			cell.Controls.Add(button);
			button.CommandName = "Update";
			button.Text = "Update";
			space = new LiteralControl(" ");
			cell.Controls.Add(space);

			button = new Button();				
			cell.Controls.Add(button);
			button.CommandName = "Delete";
			button.Text = "Delete";								
		}

		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Class, "Command");
		}

		protected override bool OnBubbleEvent(object source, EventArgs args)
		{
			CommandEventArgs args1 = args as CommandEventArgs;
			if (args1 != null)
			{
				DataOperationCommandEventArgs args2 = new DataOperationCommandEventArgs(source, args1);
				base.RaiseBubbleEvent(this, args2);
				return true;
			}
			return false;
		}

	}
}

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) www.sqlnetframework.com
Mexico Mexico
Luis Ramirez is creator and owner of ADO.NET Accelerator. You can use the FREE ADO.NET Accelerator version to reduce more than 50% ADO.NET code from your data access layer. Luis Ramirez is a Microsoft Certified Professional specialized in .NET development. If you want to contact him to work in your projects or for any other inquiry that you have write him to lramirez [at] sqlnetframework [dot] com.

Comments and Discussions