我有一个gridview,并且我正在动态创建它,我获取父表和子表记录并将数据绑定到单个数据网格视图。我需要将来自子表的行向右缩进一点,以便我可以将记录与父记录区分开来。
private void CreateDynamicGridView(DataTable tables, GridView gv)
{
try
{
DataTable _dtSearchList = tables;
strColumnCount = _dtSearchList.Columns.Count.ToString();
foreach (DataColumn col in _dtSearchList.Columns)
{
BoundField bfield = new BoundField();
bfield.DataField = col.ColumnName;
bfield.HeaderText = col.ColumnName;
gv.Columns.Add(bfield);
}
gv.DataSource = _dtSearchList;
gv.DataBind();
}
catch (Exception ex)
{
}
}