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

Multiple Column Dropdownlist for the ASP.NET DataGrid

Rate me:
Please Sign up or sign in to vote.
4.46/5 (43 votes)
1 Jun 20053 min read 423.7K   6.7K   140  
An article on multiple column dropdownlists for the ASP.NET DataGrid.
<%@ Register TagPrefix="jsk" Namespace="ddList" Assembly="ddList" %>
<%@ Page language="c#" Codebehind="buttons_cs.aspx.cs" AutoEventWireup="false" Inherits="CSharpSample.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm4</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">
		<style type="text/css">
			.cStyle { FONT-SIZE: 8pt; FONT-FAMILY: verdana,arial,helvetica,sans-serif }
		</style>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<table style="LEFT: 0px; WIDTH: 747px; POSITION: absolute; TOP: 0px; HEIGHT: 507px" height="507"
				cellSpacing="0" cellPadding="0" width="747" border="0">
				<tr>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="488" height="216">
						<div style="OVERFLOW: auto; WIDTH: 636px; HEIGHT: 215px"><asp:datagrid id="DataGrid1" runat="server" CellPadding="3" BackColor="White" BorderWidth="1px"
								BorderStyle="None" BorderColor="#CCCCCC" Font-Size="8pt" Font-Names="verdana,arial,helvetica,sans-serif" Width="459px" Height="208px">
								<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
								<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
								<ItemStyle ForeColor="#000066"></ItemStyle>
								<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
								<Columns>
									<asp:TemplateColumn HeaderText="Category Name">
										<ItemTemplate>
											<jsk:mcDDList id=McDDList1 runat="server" Width="250px" CssClass="cStyle" DataTextField="1" DataValueField="0" DataSource="<%#populateDDList()%>" ListBoxHeight="100px">
											</jsk:mcDDList>
										</ItemTemplate>
									</asp:TemplateColumn>
								</Columns>
								<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
							</asp:datagrid></div>
					</td>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="144" height="216"><asp:button id="btnInsert" runat="server" Width="101px" Text="Insert"></asp:button></td>
				</tr>
				<tr>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="488" height="207">
						<div style="OVERFLOW: auto; WIDTH: 636px; HEIGHT: 215px"><asp:datagrid id="DataGrid2" runat="server" CellPadding="3" BackColor="White" BorderWidth="1px"
								BorderStyle="None" BorderColor="#CCCCCC" Font-Size="8pt" Font-Names="verdana,arial,helvetica,sans-serif" Width="457px" Height="201px">
								<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
								<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
								<ItemStyle ForeColor="#000066"></ItemStyle>
								<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
								<Columns>
									<asp:TemplateColumn HeaderText="Category Name">
										<ItemTemplate>
											<jsk:mcDDList id=Mcddlist2 runat="server" Width="250px" CssClass="cStyle" DataTextField="1" DataValueField="0" SelectedIndex='<%# DataBinder.Eval(Container.DataItem, "categoryID") %>' DataSource="<%#populateDDList()%>" ListBoxHeight="100px">
											</jsk:mcDDList>
										</ItemTemplate>
									</asp:TemplateColumn>
								</Columns>
								<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
							</asp:datagrid></div>
					</td>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="144" height="207">&nbsp;
						<asp:button id="btnUpdate" runat="server" Width="99px" Text="Update"></asp:button></td>
				</tr>
				<tr>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="488" height="42"><jsk:mcddlist id="McDDList3" runat="server" Width="291px" CssClass="cStyle" DataTextField="1"></jsk:mcddlist></td>
					<td style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
						vAlign="top" align="left" width="144" height="42">&nbsp;
						<asp:button id="btnSubmit" runat="server" Width="100px" Text="Submit"></asp:button></td>
				</tr>
			</table>
			<input type="button" value="TEST">
		</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
United States United States
I'm a .Net Programmer/Web Developer, mostly working on ASP.Net C# and VB.Net,Oracle,SQL server 2000.

Comments and Discussions