SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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

Your Answer


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.