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

Auto-SQL DataGrid component Part II: The full-featured version

Rate me:
Please Sign up or sign in to vote.
4.36/5 (6 votes)
8 Aug 20055 min read 37.5K   943   28  
ASQLDataGrid is a useful component when working with RDBMS applications. It is capable of automatically constructing and executing SQL statements based on its properties.
<%@ Register TagPrefix="ntm" Namespace="NTM.Controls" Assembly="ASQLDataGrid" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ASQLDataGridExample.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="styles.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<table id="table1" width="90%" align="center">
				<tr>
					<td width="40%">
						<h2>Employees</h2>
					</td>
					<td><ntm:cmdbutton id="btPopEmployees" runat="server" Param="DG_Employees" Cmd="DG_POP" Text="Populate"
							Width="73"></ntm:cmdbutton><ntm:cmdbutton id="btNewEmployees" runat="server" Param="DG_Employees" Cmd="DG_NEW" Text="New"
							Width="73px"></ntm:cmdbutton><ntm:cmdbutton id="btCancelEmployees" runat="server" Param="DG_Employees" Cmd="DG_CANCEL" Text="Cancel"
							Width="73px"></ntm:cmdbutton><ntm:cmdbutton id="btSaveEmployees" runat="server" Param="DG_Employees" Cmd="DG_SAVE" Text="Save"
							Width="73px"></ntm:cmdbutton></td>
				</tr>
				<tr>
					<td colSpan="2"></td>
				</tr>
				<tr>
					<td colSpan="2"><ntm:asqldatagrid id="DG_Employees" runat="server" width="100%" AutoGenerateColumns="False" ListOfPKColumns="0">
							<AlternatingItemStyle CssClass="GridAltItem"></AlternatingItemStyle>
							<ItemStyle CssClass="GridItem"></ItemStyle>
							<HeaderStyle CssClass="GridHeader"></HeaderStyle>
							<Columns>
								<asp:BoundColumn DataField="EmployeeID" ReadOnly="True" HeaderText="ID">
									<HeaderStyle Width="7%"></HeaderStyle>
								</asp:BoundColumn>
								<asp:BoundColumn DataField="TitleOfCourtesy" HeaderText="Title">
									<HeaderStyle Width="5%"></HeaderStyle>
								</asp:BoundColumn>
								<asp:BoundColumn DataField="FirstName" HeaderText="First name">
									<HeaderStyle Width="10%"></HeaderStyle>
								</asp:BoundColumn>
								<asp:BoundColumn DataField="LastName" HeaderText="Last name">
									<HeaderStyle Width="10%"></HeaderStyle>
								</asp:BoundColumn>
								<asp:BoundColumn DataField="BirthDate" HeaderText="Birth date" DataFormatString="{0:MM-dd-yyyy}">
									<HeaderStyle Width="10%"></HeaderStyle>
								</asp:BoundColumn>
								<asp:BoundColumn DataField="Address" HeaderText="Address"></asp:BoundColumn>
								<asp:TemplateColumn HeaderText="Reports to">
									<ItemTemplate>
										<%#DataBinder.Eval(Container.DataItem, "ReportsTo")%>
									</ItemTemplate>
									<EditItemTemplate>
										<asp:DropDownList id="DropDownList1" runat="server" Width="146px"></asp:DropDownList>
									</EditItemTemplate>
								</asp:TemplateColumn>
								<ntm:CmdButtonColumn HeaderText="Edit" Cmd="DG_EDIT" PreStatement="" LabelText="" ButtonText="Edit"></ntm:CmdButtonColumn>
								<ntm:CmdButtonColumn HeaderText="Delete" Cmd="DG_DELETE" PreStatement="if (!confirm('Are you sure to delete this data?')) return false;"
									LabelText="" ButtonText="Delete"></ntm:CmdButtonColumn>
							</Columns>
							<PagerStyle Visible="False"></PagerStyle>
						</ntm:asqldatagrid></td>
				</tr>
			</table>
		</form>
	</body>
</HTML>

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Vietnam Vietnam
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions