asp.net 程序动态添加gridview
前台:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="divshow" runat="server" >
</div>
</form>
</body>
</html>
后台:
GridView gvshow=null;
public void setBind()
{
DataTable dt = getDataTable(); //获得数据源
gvshow = new GridView();
gvshow.Width = Unit.Pixel(800);
gvshow.AutoGenerateColumns = false;
gvshow.RowDataBound += new GridViewRowEventHandler(gvshow_RowDataBind);
gvshow.RowDeleting +=new GridViewDeleteEventHandler(gvshow_RowDeleting);
gvshow.DataSource = dt;
for (int i = 0; i < dt.Columns.Count; i++)
{
BoundField bc = new BoundField();
bc.DataField = dt.Columns[i].ColumnName.ToString();
for (int i = 0; i < dt.Columns.Count; i++)
{
BoundField bc = new BoundField();
bc.DataField = dt.Columns[i].ColumnName.ToString();
&
相关文档:
首先法方有3个,这里就说2个实用的。。。
1,直接为 控件 innerhtml 添加值
2,createElement (创建COM)
3,后台 NEW 控件,添加
这里说下 1,2 两个法方!
1:
动态生成 字符串 string inntext=" <table> <tr> <td style=width:300px;text-align:right; >{0}<input id={1} type=text c ......
(1)首先要对内容的特殊字符进行过虑:
C# 代码:
public string res(string partno)
{
partno = partno.Replace("&", "");
partno = partno.Replace("/", "");
partno = partno.Replace("&", "");
return partno;
}
(2)从数据库中获得要生成地图的内 ......
先建个html模版页(template.htm):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>$title</title>
& ......
第一种方法是对一个aspx页面生成html文件,先对服务器发送请求aspx页面,取服务器返回的html流,写到一个html文件里,aspx页面显示的是什么,生成的html页面就是什么
1、asp方法:
sub createHTML
dim xmlhttp,strhtml,objAdoStream,i,myurl
set xmlhttp=server.CreateObject("Microsoft.XMLHTTP")
&nb ......