BoundColumn NumberColumn = new BoundColumn();
NumberColumn.HeaderText="Item Number";
NumberColumn.DataField="IntegerValue";
把以上增加的列动态的添加到DataGrid里面;
// Add column to Columns collection.
DataGrid.Columns.AddAt(2, NumberColumn);
DataGrid.DataSouce=ds;
DataGrid.DataBind();
==============================================
DataGrid显示双层表头假设你的DataGrid有三列,现在想将前两列作为"大类1",第三列作为"大类2",现在,你可以在ItemDataBound事件中加入下面的代码:
if (e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[0].ColumnSpan = 2;
e.Item.Cells[0].Text = "大类1</td><td>大类2</td></tr><tr><td>" + e.Item.Cells[0].Text;
}
用这个方法可以为任意添加新行。
NumberColumn.HeaderText="Item Number";
NumberColumn.DataField="IntegerValue";
把以上增加的列动态的添加到DataGrid里面;
// Add column to Columns collection.
DataGrid.Columns.AddAt(2, NumberColumn);
DataGrid.DataSouce=ds;
DataGrid.DataBind();
==============================================
DataGrid显示双层表头假设你的DataGrid有三列,现在想将前两列作为"大类1",第三列作为"大类2",现在,你可以在ItemDataBound事件中加入下面的代码:
if (e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[0].ColumnSpan = 2;
e.Item.Cells[0].Text = "大类1</td><td>大类2</td></tr><tr><td>" + e.Item.Cells[0].Text;
}
用这个方法可以为任意添加新行。
http://xml.sz.luohuedu.net/xml/Content.asp
http://aspalliance.com/Colt/Articles/Article3.aspx
http://xml.sz.luohuedu.net/xml/ShowList.asp?id=1
首先它必须是一个完整的行。
如果使用Footer,那么动态添加列将会导致Footer被分在最初的列中,
好像无法动态添加Footer不知道各位的动态添加行,末尾行是摘要信息的datagrid控件
是不是都用做好的模板,而不用在初始化是动态添加列?等待~~~