Display fields from a view in gridview
while creating grid view column checkSPView view = curList.Views[Convert.ToString(Property2)];
SPListItemCollection oitem = curList.GetItems(view);
ViewTable = oitem.GetDataTable();
foreach (DataColumn column in ViewTable.Columns)
{
if (view.ViewFields.Exists(column.ColumnName))
{
BoundField Boundcolumn = new BoundField();
Boundcolumn.DataField = column.ColumnName;
Boundcolumn.HeaderText = column.ColumnName;
Boundcolumn.SortExpression = column.Caption;
gdv.Columns.Add(Boundcolumn);
}
}
No comments:
Post a Comment