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 have custom webpart which gets data from external database using BCS. When I add the webpart in a webpart zone, it queries the BDC to get data so it take time to insert webpart. I only want to query data in display mode.

share|improve this question
please use some punctuation and clarify your question. Actually, there is no question in your words. Read the How to Ask page for more help. – Steve B Jul 13 '12 at 12:07

Assuming you have created this WebPart yourself, you should check the SPControlMode. Example:

        if (SPContext.Current.FormContext.FormMode != SPControlMode.Edit)
            //Query BDC
share|improve this answer
This is not working as i am getting FormMode Invalid. – Ronak Jul 16 '12 at 14:01
Could you please clarify? Is FormMode populated with a 0 / SPControlMode.Invalid? – J Torres Jul 16 '12 at 14:44
Hi Torres it populated with Invalid in design mode meaning when i try to add webpart. – Ronak Jul 16 '12 at 20:38
I'm at a loss here as I use this on a regular basis for disabling RequiredFieldValidators. Is there something unusual about your particular setup? – J Torres Jul 17 '12 at 13:44

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.