我创建了自定义列表 Web 部件并在主页中使用该 Web 部件。当我单击项目时,它没有在对话框中打开。我使用了下面的代码。
谁能建议我有什么问题?
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
query.RowLimit = Convert.ToUInt16(RowLimit);
SPList list = web.Lists[ListName];
SPListItemCollection listItemsCollection = list.GetItems(query);
foreach (SPListItem listItem in listItemsCollection)
{
TableRow tableRow = new TableRow();
TableCell tableCell = new TableCell();
HyperLink link = new HyperLink();
string docName = listItem.Title;
link.Text = docName;
try
{
link.NavigateUrl = web.ParentWeb.Url + list.DefaultDisplayFormUrl + "?id=" + listItem.ID + "&IsDlg=1";
}
catch (Exception ex)
{
link.NavigateUrl = web.Url + list.DefaultDisplayFormUrl + "?id=" + listItem.ID ;
}
//link.Target = "_parent";
tableCell.Controls.Add(link);
tableRow.Cells.Add(tableCell);
table.Rows.Add(tableRow);
}
this.Controls.Add(table);