2013-08-27 13 views
0

您能否告诉我如何在SPGridView的NavigateURL中使用当前项目ID。 以下是代码示例。如果我使用Eval,它会给出运行时错误。 请帮我在这种情况下..如何在SPGridview中使用当前项目ID

<SharePoint:SPGridView runat="server" ID="gdvSearchResults" width="50%" AllowSorting="True" 
    AutoGenerateSelectButton="false" AutoGenerateColumns="false"> 
    <Columns> 
      <SharePoint:SPBoundField runat="server" DataField="Attachments" HeaderText="Attachments" SortExpression="Attachments" /> 
      <SharePoint:SPBoundField runat="server" DataField="Practice" HeaderText="Practice" /> 
      <asp:HyperLinkField DataTextField="ID" HeaderText="Require_x0020_Details_x0020__x00" NavigateUrl="http://server/sites/TestingCollection/TestLists/Send%20Mail/EditForm.aspx?ID="+ID/>   
    </Columns> 
    </SharePoint:SPGridView> 

在此先感谢!

回答

1

使用下面的更改解决它在我的网格。

<SharePoint:SPGridView runat="server" ID="gdvSearchResults" width="50%" AllowSorting="True" 
AutoGenerateSelectButton="false" AutoGenerateColumns="false"> 
<Columns> 
     <SharePoint:SPBoundField runat="server" DataField="Attachments" HeaderText="Attachments" SortExpression="Attachments" /> 
     <SharePoint:SPBoundField runat="server" DataField="Practice" HeaderText="Practice" /> 
     <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="~/EditForm.aspx?ID={0}" DataTextField="ID" HeaderText="ID" /> 
</Columns> 
</SharePoint:SPGridView>