Thursday, May 31, 2012

VS 2010 RDLC Report Fixed header

Im creating one rdlc report in VS 2010.

I am using tablix.

I wanted fixed header.

After struggling sometime, I could  find the solution.

here is the way.

After you design the report, see bottom of your report. You can find "Row Groups" & "Column Groups"
section.

 for column groups there will be a down arrow button. click the button. You will get "Advanced Mode"  menu.

then you can see the two rows in "row groups" section.

first one (static) is header section. second one(details) is details section.

select the static row and click F4. it opens properties window.

then set FixedData to TRUE.







Wednesday, May 30, 2012

Get currency value from a string contains $

Here is a quick way to get the currency value from a string which contains "$" and ",".

Some  may struggle to remove the "$" and  ","

but here is the way

Double pdblValue = Double.Parse("$96,000.00", NumberStyles.Any);


it needs a reference to "System.Globalization"  namespace

A Web Part with this ID has already been added to this page

Recently I was playing with adding webparts programatically.

Then I got this error "A Web Part with this ID has already been added to this page"

tried to use contents=1, but no use . it says page could not found

finally found the below link

http://dpruna.blogspot.com/2011/11/web-part-with-this-id-has-already-been.html

Thanks to author.


using the following procedure we can find out the webparts added to the given page.

Note:- it contains webparts added by all the users. (Not only you)

it gives you list of webparts added to that page (problamatic duplicate webparts aswell). Then you know what to do.

delete the webpart wisely

if it is dev server then may be less issues, but if it is Production server.........be careful

Here is the procedure.

Note:- My list exists in subsite ("ABC"). So I had to use @DocDirName = N'ABC/Lists/Raportari',


declare @DocDirName nvarchar(255),
        @DocLeafName nvarchar(255),
        @SiteId uniqueidentifier,
        @DocId uniqueidentifier,
        @DocParentId uniqueidentifier,
        @Level int
 
select  @SiteId = '88501D83-5339-4745-827F-0C7454F9B7BD',
        @DocDirName = N'Lists/Raportari',
        @DocLeafName = N'EditForm.aspx',
        @Level = 1
 
SELECT TOP 1  
    @DocParentId = ParentId,  
    @DocId = Id  
FROM  
    TVF_Docs_NoLock_Url(@SiteId, @DocDirName, @DocLeafName) AS Docs  
 
SELECT  
    WP.tp_ID,  
    WP.tp_WebPartTypeId,  
    WP.tp_Assembly,  
    WP.tp_Class,
    WP.tp_SolutionId,  
    WP.tp_AllUsersProperties,    
    WP.tp_WebPartIdProperty,
    WP.tp_Version,  
    WP.tp_Cache,  
    (N'{' + CAST(WP.tp_ListId AS nvarchar(36)) + N'}') AS tp_ListId,  
    WP.tp_Type,  
    WP.tp_Source,  
    WP.tp_BaseViewID,  
    WP.tp_View,  
    WP.tp_CreationTime  
FROM  
    AllWebParts AS WP WITH (INDEX=PageUrlID_FK)
WHERE  
    tp_SiteId = @SiteId AND  
    tp_IsCurrentVersion = CONVERT(bit, 1) AND  
    tp_PageUrlID = @DocId AND  
    tp_PageVersion = 0 AND  
    tp_Level = @Level

Wednesday, May 23, 2012

remove user from sharepoint group

The trick is

SPUser user = web.EnsureUser(peCheckUser.Accounts[0].ToString());

                            SPGroupCollection collGroups = user.Groups;
                            if (collGroups.Count > 0)
                            {
                                foreach (SPGroup oGroup in collGroups)
                                {
                                    oGroup.RemoveUser(user);
                                }
                                strError += "User Removed Successfully...!";
                            }


thanks to author @ http://sharepoint2010tutorialnew.blogspot.com/2011/12/deleting-user-within-sharepoint-group.html


Sunday, May 20, 2012

c# , display number in thousands seperator format


 NumberFormatInfo nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
            nfi.NumberGroupSeparator = ",";
            Console.WriteLine(12345.ToString("n", nfi)); // 12,345.00

for my surprise it includes the decimal poiont at last. it made my job easy....:-)

thanks to author @ http://stackoverflow.com/questions/752145/use-a-custom-thousand-separator-in-c-sharp


Tuesday, May 1, 2012

SharePoint : thread was being aborted

I was getting "Thread was being aborted" error while running my workflow. My Workflow required 5-10 mins to finish. but after 2 or 3 mins I started my workflow, it was throwing this error. which i got from my error log.

I could Identify that, the error is coming in different steps (workflow activities) everytime. It means problem is neither with data nor with the code.

then after searching for sometime. I found this article @

http://dirkvandenberghe.com/2010/01/29/sharepoint-timeout-error-thread-was-being-aborted.html

thanks to author.


the actual problem is sharepoint execution time.

The solution to the problem is
<httpRuntime executionTimeout=200 maxRequestLength=51200/>

try to find the "<httpruntime"  element in your sharepoint's web application's web.config file and include this attribute.  " executionTimeout=2000“ "


I changed it to "2000". now the problem is solved. (at least for me)

this may help to those who overlooked this check.