日期:2014-05-20  浏览次数:20366 次

|M| 第二贴:如何在DataGrid绑定的时候动态复制添加我页面中dg_Item到行中
原贴:
http://community.csdn.net/Expert/topic/5324/5324183.xml?temp=.1363336
我是这样的
我有DataGrid,然后在他绑定的时候让他加多一行来绑定其他的表如下是幕白兄的代码:
DataGridItem   item   =   e.Item;
                //GridViewRow   NewRow   =   new   GridViewRow(0,   0,   DataControlRowType.DataRow,   DataControlRowState.Normal);
                DataGridItem   NewItem   =   new   DataGridItem(0,   0,   ListItemType.Item);
                NewItem.Cells.Add(new   TableCell());
                NewItem.Cells[0].ColumnSpan   =   item.Cells.Count;
                NewItem.Style.Add( "display ",   "none ");

                dgMovie.Controls[0].Controls.Add(NewItem);
                DataGrid   dg   =   new   DataGrid();
                dg.DataSource   =   MovieOrder.GetList();
                dg.DataBind();
                NewItem.Cells[0].Controls.Add(dg);        
现在可以实现我给DataGrid的行绑定多一个DataGrid的问题
但是因为是new   DataGrid我设计他里面的样式和绑定内容如果都用代码来写的话很是麻烦

然后我就在外面自己设计了一个DataGrid然后代码为:
DataGridItem   item   =   e.Item;
                //GridViewRow   NewRow   =   new   GridViewRow(0,   0,   DataControlRowType.DataRow,   DataControlRowState.Normal);
                DataGridItem   NewItem   =   new   DataGridItem(0,   0,   ListItemType.Item);
                NewItem.Cells.Add(new   TableCell());
                NewItem.Cells[0].ColumnSpan   =   item.Cells.Count;
                NewItem.Style.Add( "display ",   "none ");

                dgMovie.Controls[0].Controls.Add(NewItem);
                DataGrid   dg   =   mydg;       //这里是我自己设计的代码
                dg.DataSource   =   MovieOrder.GetList();
                dg.DataBind();
                NewItem.Cells[0].Controls.Add(dg);        
本来以为这样是可行的,但是程序运行的时候有生成多一个行,但却没有生成我要的那个DataGrid

谢谢,上面要怎么改


------解决方案--------------------
全是接分的.
我也顺便接点分把
------解决方案--------------------
不是没有,应该至少有一个吧?
------解决方案--------------------