Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've created a custom webpart that shows me some details of a dossier. I've added a DossierID property like this:

public Guid DossierId { get; set; }

This identifies the dossier from which I want to see the details.

I also have a BCS list with dossiers. I've placed my custom webpart on the dispform of this list. I can retrieve the current ID with

HttpContext.Current.Request.QueryString["ID"];

But I don't like to do that because then I can't use my webpart in a place where I don't have an ID in the querystring.

Is there a way to bind the ID used in the querystring of dispform.aspx to the property of my custom webpart?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I'd create a property for the Id in the webpart, which allows the user putting the web-part on a page to specify the id to use.

Where you need the Id in the code you could do the check to see if the Id property was set, then use that otherwise use the one from the QueryString and if that's missing fail.

Then you could add the webpart to dispform.aspx without setting the property and it'll work as before.

Adding it to another page you could set the Id in the properties.

share|improve this answer
add comment

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.