Question

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!

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top