如何在SPGridview中使用当前项ID

时间:2013-08-27 07:53:19

标签: sharepoint-2010 spgridview

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

<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 个答案:

答案 0 :(得分: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>