首页  ·  知识 ·  云计算
动态生成asp.net控件
佚名  http://www.51one.net  综合  编辑:dezai  图片来源:网络
public void CreateDataGrid() { DataTable flowTable=new WorkFlowBLL().GetFlowTableByCode(FunctionCode); foreach(DataRow dataRow in flowTab
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") ;
}
}
本文作者:佚名 来源:http://www.51one.net
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读