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

Edit and Delete multiple Data in DataGrid in ASP.NET

Rate me:
Please Sign up or sign in to vote.
3.08/5 (12 votes)
18 Apr 2007 95.2K   2.5K   41  
Edit and Delete multiple Data in DataGrid in ASP.NET
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="DelhiApp.Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="1">
				<TR>
					<TD></TD>
				</TR>
				<TR>
					<TD>
						<asp:Panel id="Panel3" runat="server">Edit<BR>
<asp:DataGrid id="DataGrid2" runat="server" AutoGenerateColumns="False" GridLines="Vertical" CellPadding="3"
								BorderStyle="None" DataKeyField="empId" BorderWidth="1px" BorderColor="#999999"
								BackColor="White">
								<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
								<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
								<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
								<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
								<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
								<Columns>
									<asp:BoundColumn DataField="empId" ReadOnly="True" HeaderText="Emp ID"></asp:BoundColumn>
									<asp:BoundColumn DataField="empName" HeaderText="Emp Name"></asp:BoundColumn>
									<asp:BoundColumn DataField="salary" HeaderText="Salary"></asp:BoundColumn>
									<asp:BoundColumn DataField="joiningDate" HeaderText="Joining Date "></asp:BoundColumn>
									<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" HeaderText="Edit" CancelText="Cancel"
										EditText="Edit"></asp:EditCommandColumn>
									<asp:ButtonColumn Text="Delete" ButtonType="PushButton" HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
									<asp:TemplateColumn HeaderText="Select">
										<ItemTemplate>
											<asp:CheckBox id="cbSelected" runat="server"></asp:CheckBox>
										</ItemTemplate>
									</asp:TemplateColumn>
								</Columns>
								<PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle>
							</asp:DataGrid>
      <P>
								<asp:Button id="Button2" runat="server" Text="Delete All"></asp:Button></P>
      <P>&nbsp;</P></asp:Panel></TD>
				</TR>
				<TR>
					<TD></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 TATA Communications
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions