动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   .Net → 阅读文章

 动态生成asp.net控件

作者来源: 
阅读 数 367 人次 , 2006-3-29 4:35:00 

public void createdatagrid()
{
datatable flowtable=new workflowbll().getflowtablebycode(functioncode);
foreach(datarow datarow in flowtable.rows)
{
table table=new table();
table.cellpadding=0;
table.cellspacing=0;
table.width=unit.percentage(98);
table.attributes.add("align","center");
table.attributes.add("style","height:expression(document.body.offsetheight-toolbar.offsetheight-spacebar.offsetheight-33)");
table.cssclass="plpanelunselect";
table.attributes.add("imagessrc","images/contact.gif");
table.attributes.add("panelcaption",(string)datarow["bmc"]);
tablerow tablerow=new tablerow();
tablecell tablecell=new tablecell();
tablecell.verticalalign=verticalalign.top;
panel panel=new panel();
panel.attributes.add("style","overflow: auto; width: 100%; height: 100%");
datagrid=new datagrid();
datagrid.borderwidth=0;
datagrid.id=(string)datarow["bdm"];
datagrid.enableviewstate=false;
datagrid.width=unit.percentage(100);
datagrid.font.size=fontunit.parse("12px");
datagrid.style["border-collapse"]="none";
datagrid.itemdatabound += new datagriditemeventhandler(datagrid_itemdatabound);
datagrid.datasource=new workflowbll().getflowdatabycode(functioncode,(string)datarow["bdm"],datacode);
datagrid.databind();
panel.controls.add(datagrid);
tablecell.controls.add(panel);
tablerow.cells.add(tablecell);
table.rows.add(tablerow);
placeholder.controls.add(table);
}
}
private void datagrid_itemdatabound(object sender, system.web.ui.webcontrols.datagriditemeventargs e)
{
if ((e.item.itemtype==listitemtype.item)||(e.item.itemtype==listitemtype.alternatingitem))
{
htmlinputtext inputtext=new htmlinputtext();
inputtext.attributes.add("class","clsinput");
inputtext.value= e.item.cells[1].text;
//getflowwrite
e.item.cells[1].controls.add(inputtext);
}
for (int i=0;i {
if (e.item.itemtype==listitemtype.header)
{
e.item.cells[i].attributes.add("class","irtitle");
}
else{
e.item.attributes.add("class","irbody");
e.item.attributes.add("overclassname","irbodyover");
e.item.attributes.add("cssclick","irbodyclick");
}
e.item.cells[i].attributes.add("align","center");
e.item.cells[i].attributes.add("width",convert.tostring(100/e.item.cells.count)+"%");
e.item.cells[i].attributes.add("nowrap","true") ;
}
}
 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:如何实现Asp与Asp.Net共享Session
· 下一篇:ASP.NET用户控件返回事件的方法
· ASP.NET创建XML Web服务全接触(15)
· C#中的域(field)和属性(property)
· 创建完全可编辑的 DataGrid
· Win中Net命令的另类用法
· ASP.NET之精通弹出窗口


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077