動態產生asp.net控制項

來源:互聯網
上載者:User
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") ;
}
}
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.