public void loadHeaderActionTable()
{
SPWeb web = SPContext.Current.Web;
SPList actionList = web.Lists[ActionListName];
SPListItemCollection actions = actionList.GetItems(myActionListView);
TableRow header = new TableRow();
foreach (SPField fItem in actions.Fields)
{
if (!fItem.Hidden
&& myActionListView.ViewFields.Exists(fItem.InternalName))
{
TableCell cItem = new TableCell();
cItem.Text = fItem.Title.ToString();
cItem.CssClass = "ms-vh-div";
header.Cells.Add(cItem);
myActionColumnTitle.Add(cItem.Text);
}
}
tblACList.Rows.Add(header);
}
Monday, 27 February 2012
Load a List Table dynamically with columns
This took me a while to figure out, for predefined fields like ID, Modified, Created, Title, it will still have a Hidden=True even though it is not shown in AllItems.aspx. Thus I have to check it by using the Exists method.
Labels:
SPGridView
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment