Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created one visual Webpart, it is having one Grid Control to display the items but that items having a link to open current item URL (Like Display Item)?

share|improve this question
What is exacly your question? You have a Grid with all Items and now you want to add the link to the item? – yannisgu Sep 3 '12 at 13:06

1 Answer

Suppose you are using the datatable to populate the grid. the sample code to build the title navigation url will look something like this:

//Build hyperlink for title...
string itemID = dt.Rows[i]["ID"].ToString();
string listID = dt.Rows[i]["ListId"].ToString();

Guid guid = new Guid(listID);
SPList list = web.Lists[guid];

string displayUrl = list.DefaultDisplayFormUrl;
string navUrl = displayUrl + "/DispForm.aspx?ID=" + itemID;
dt.Rows[i]["TitleNavigationUrl"] = navUrl;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.