Thursday, November 4, 2010

GridView value set to null when column is not visible

You made an Update method to take care of updating your gridview, but there are some columns that are not needed to be shown in the default gridview but you do need them in the update method.
Then, when you try to use those columns data in your method, you will see they have null even though they had value in them...

What can you do then ?

Write those column name in the DataKeyNames section of gridview control. Then, those columns will be available and not with null value in your update method.
 



Good luck.

Saturday, October 16, 2010

How to save scroll location after postback ?

There are two options for that - to implement it with javascript or server side.

The server side implementation is very simple, we will have to do a small change in the web.config file.

 





Be aware - more work on the server side, more memory being consumed. But this method is very quick to implement.

Good Luck.

Sunday, September 12, 2010

"FileNotFoundException was unhandled" SharePoint 2010 newbies error

היי,

את השגיאה שבנושא קיבלתי בעת הרצת האפליקציה על מכונה חדשה שהתקנתי.

בעת הרצת אפליקציית קונסול יש לוודא לאיזו פלטפורמה מגודרת האפליקציה. כברירת מחדל , אפילו על מכונת 64 ביט, הויז'ואל סטודיו מותאם לרוץ לפלטפורמה של 32 ביט. לכן בעת ריצה ושימוש בקלאסים של שרפוינט , אנחנו נעוף מהסיבה הפשוטה שהם מותאמים ל 64 ביט, אז ברגע שננסה להשתמש באובייקט ששייך לשרפוינט נעוף על השגיאה שבנושא.

הפתרון פשוט מאוד - לכו להגדרות הפרויקט/אפליקציה שלכם , ועדכנו תחת הגדרות הבנייה (build) שזה ירוץ על סביבת 64 ביט.

שימו לב, שרפוינט רץ היטב רק בדוט נט 3.5 אם תחליפו את הפרויקט שלכם ל4 ( למשל , בשביל להשתמש ביכולות יותר מתקדמות לרכיבי אופיס ) גם תקבלו תעופה.

בהצלחה.

"FileNotFoundException was unhandled" SharePoint 2010 newbies error

Hi,

Some error that I had just when I started working on the SharePoint 2010 machine. I tried to investigate the SharePoint 2010 API , but surprisingly even trying to create an SPSite object cause a runtime error.

The reason is that you Visual Studio is set for running a 32 bit application, and SharePoint 2010 is 64 bit of course.

The only thing you need to do is to go to the properties of your application/project, then change under the Build tab - the platform target to x64.

Now re-run your console application.

Done.

Tuesday, August 10, 2010

Unexpected Error - When attempting to check "User notifcations". BUG!

Hey,

Today I came across with a very annoying bug when you try to get into the "user notifications" under "site actions".

When you press that link you might get an "unexpected error" - with not much info in the event viewer, nothing if you change the custom errors to off ( in the web.config ). That made me read the Moss log and to see that im being thorwen away with THE famous error AKA "null object refernce".

This made me realize that from some odd reason I have nothing under this link or in other words its not initialized at all...

Then I made a subscription in that web site to some doclib and afterwards I was able to reach that page ( sub*.aspx , forgot the name :) ) and to see that info. Deleting my subscription made the page unavilable again.

So instead of checking if the site has any subscription at all and just prompt some more friendly message or letting you know that there is no subscription to the site -it throws you off with this unexpected error...

It always unexpected when you program wrong. Please check for Nulls.

Thanks.

**This issue was checked on a Moss farm with SP2 and Cumulative update June 2009

שגיאה בלתי צפויה - התראות משתמש

היי,


היום לצערי נתקלתי בעוד באג בפלטפורמה המופלאה שלנו...


כאשר מנסים לגשת באתר תחת "הגדרות אתר" ל"התראות משתמש" מקבלים את ההודעה הברורה - "שגיאה בלתי צפויה"


לצערי לא היו לוגים רלוונטים ברמת השרת, לאחר שינוי ברמת האתר הוירטואלי לראות לוגים ע"י שינוי ה custom erros ברמת ה Web.config


בסופו של דבר נברתי בלוגים של המערכת וראיתי שאני עף על שגיאה של

"The object reference set to null"


דבר שהוביל אותי לחשוד שאני מצביע על כלום איכשהו, ואז נפל לי האסימון שככל הנראה אני עף כי אין בכלל מנויים להתראות ברמת האתר הספציפי הזה...


ברגע שהוספתי מנוי התראה לרשימה כלשהי באתר, האפשרות "התראות משתמש" חזרה לעבוד, הסרת המנוי החזירה את השגיאה...


מילות סיכום, אם אין מנויים באתר - אין אפשרות לראות "התראות משתמש"



תודה.

Wednesday, July 21, 2010

Access Denied and Content type - who changed PermMask ?

Hello,

I wrote about this issue a while ago , and back then I came across with some hotfix tha was released from MS.

Since I saw this error again a few weeks ago, and I tried to fix it with this small utility - It brought me to the conclusion that their solution is not good enough.

Why ? several reasons -

1. It fix only one list, so you can of course iterate via all lists in the sites. But it still won’t solve the issue for new lists in that siteCollection.
2. It doesn't solve the damage that was done in the site collection level.
3. Through their code , you can't really understand how it connects to content type at all.

So what really happened then ?

By editing the list or the site with some editor, the content type that represent the permission mask in any list/doclib might have damaged. That content type is being reproduced itself in any list, so any new lists in a infected site, will be with this error as well.

So how do you really fix it ? After fixing the all the infected lists, by fixing their schema ( adding the missing attribute ), you need to fix that content type in the site collection level. How to do that - fix the content type in SPSite.RootWeb.

To sum things up, each content type has a definition which include the fields of that content type.

one of the fields is missing and you already know what to add ( check the code in my older post ) - that simple, but thats not documented.

Hope now you know what you need to fix when you get an Access denied on every item when you try to edit it !

Good Luck!