last time and brother Haidong discussed this issue, but his head has no line, so with the div form to achieve, realize the function display table, the code is as follows (background. cs file As long as the binding data can be, the field and the front bound of the agreement on OK, this does not add to repeat):
<%@ Page language= "C #" codebehind= "Dg1.aspx.cs" autoeventwireup= "false" inherits= "NETLEARN.DG1"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>dg1</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 Window.onload ()
{
var dg = document.getElementById (' DataGrid1 ');
var strhtml = "";
for (var i=1; i<dg.rows.length;i++)
{
strHTML + = dg.rows[i].cells[0].innerhtml;
}
dg.rows[1].cells[0].innerhtml = "<div id= ' dgcontent ' style= ' height:250px;overflow-y:scroll ' >" + StrHTML + "</ Div> ";
for (var i=dg.rows.length-1; i>1;i--)
{
Dg.deleterow (i);
}
}
</script>
</HEAD>
<body ms_positioning= "FlowLayout" >
<form id= "Form1" method= "POST" runat= "Server" >
<font face= "Song Body" >
<asp:datagrid id= "DATAGRID1" runat= "Server" width= "576px" height= "192px" autogeneratecolumns= "False"
Borderwidth= "0px" cellpadding= "0" >
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<table cellpadding= "2" cellspacing= "1" bgcolor= "paleturquoise" width= "100%" >
<tr>
<th bgcolor= "#006699" width= "25%" align= "center" style= "color: #ffffff" >
Serial number </td>
<th bgcolor= "#006699" width= "25%" align= "center" style= "color: #ffffff" >
ID number </td>
<th bgcolor= "#006699" width= "25%" align= "center" style= "color: #ffffff" >
Name </td>
<th bgcolor= "#006699" width= "25%" align= "center" style= "color: #ffffff" >
Age </td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding= "2" cellspacing= "1" bgcolor= "paleturquoise" width= "100%" >
<tr>
<TD bgcolor= "Lightskyblue" width= "25%" style= "padding-left:10px"; ><% #Container .itemindex+1%></td>
<TD bgcolor= "Lightskyblue" width= "25%" style= "padding-left:10px"; ><% #DataBinder. Eval (Container.DataItem, "ID")%></td>
<TD bgcolor= "Lightskyblue" width= "25%" style= "padding-left:10px"; ><% #DataBinder. Eval (Container.DataItem, "Name")%></td>
<TD bgcolor= "Lightskyblue" width= "23%" style= "padding-left:10px"; ><% #DataBinder. Eval (Container.DataItem, "age")%></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></FONT></form>
</body>
</HTML>
Total 2 page: previous 1 [2] Next page