简体   繁体   中英

How to use current item id in SPGridview

Can you please tell me how do i use current item id in the NavigateURL in SPGridView. Below is the code sample. If I use Eval it is giving run time error. Please help me in this case..

<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>

Thanks in advance!

Resolved it using the below changes in my grid.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM