功能齐全的DataGrid
//目前功能:排序、单选项、复选项、合并单元格、产生序列号、联动下拉框、鼠标移动改变颜色、奇偶项颜色区分
//后续再加:分页、统计
1.html代码
<HTML>
<HEAD>
<title>DatagridTest</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">
<script language="javascript">
function fun_option(obj)
{
document.Form1.hiduserid.value=obj.value;
alert(obj.value);
}
function chkAll_true()
{
var chkall= document.all["chkAll"];
var chkother= document.all["chkExport"];
if(chkother.length>0)
{
for (var i=0;i<chkother.length;i++)
{
if(chkall.checked==true)
{
chkother[i].checked=true;
}
else
{
chkother[i].checked=false;
}
}
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" height="100%" cellSpacing="1" cellPadding="1" width="100%" border="1">
<tr height="30">
<td><INPUT id="chkAll" onclick="chkAll_true()" type="checkbox">全选/取消</td>
</tr>
<TR vAlign="top">
<TD width="100%"><asp:datagrid id="DataGrid1" runat="server" ForeColor="Black"
GridLines="None" CellPadding="2"
BackColor="LightGoldenrodYellow" BorderWidth="1px" BorderColor="Tan"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyField="UserID" OnUpdateCommand="Update" OnCancelCommand="Cancel"
OnEditCommand="Edit">
<FooterStyle BackColor="Tan"></FooterStyle>
<SelectedItemStyle ForeColor="GhostWhite"
BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="No">
<ItemTemplate>
<INPUT id="radio" type="radio" name="radio"
onclick="fun_option(this)" value='<%# DataBinder.Eval(Container.DataItem,"UserID") %>'>