Thursday, May 30, 2013

Nettiers Gridview Export to Excel

So, I'm trying to get (back) into the habit of posting information that I found to be helpful and this post is going to address an issue with exporting gridview contents to Excel.  In particular, I was using nettiers EntityGridView and getting a RegisterForEventValidation error when clicking the export link, but the same could apply to a regular gridview as well I think.  I didn't want to turn off event validation and leave a security hole (as I did have user input fields on the page) and was looking for another way to work around this.  We were using .netTiers v2.3.0.807 and I didn't want to mess with the template file so I found a way to handle it in the aspx page that contained the control.

Nettiers provides an event that gets called prior to the export called OnExcelBeforeFormat as well as after the export called OnExcelAfterFormat.  Our gridview used sorting, paging, and had checkboxes in some columns. 

By using this code, I was able to avoid the issue without turning off event validation or messing with the template...

///
/// Replace any of the contained controls with literals
///
///
private static void PrepareControlForExport(Control control)
{
  for (int i = 0; i < control.Controls.Count; i++)
  {
      Control current = control.Controls[i];
      if (current is LinkButton)
     {
        control.Controls.Remove(current);
        control.Controls.AddAt(i, new LiteralControl((current as LinkButton).Text));
      }
      else if (current is ImageButton)
      {
        control.Controls.Remove(current);
        control.Controls.AddAt(i, new LiteralControl((current as ImageButton).AlternateText));
      }
      else if (current is HyperLink)
      {
        control.Controls.Remove(current);
        control.Controls.AddAt(i, new LiteralControl((current as HyperLink).Text));
      }
      else if (current is DropDownList)
      {
        control.Controls.Remove(current);
        control.Controls.AddAt(i, new LiteralControl((current as DropDownList).SelectedItem.Text));
      }
      else if (current is CheckBox)
      {
        control.Controls.Remove(current);
        control.Controls.AddAt(i, new LiteralControl((current as CheckBox).Checked ? "True" : "False")) ;
      }
      if (current.HasControls())
      {
         PrepareControlForExport(current);
       }

   }
}



protected void GridView_OnExcelBeforeFormat(object sender, EventArgs e)
{
     PrepareControlForExport(GridView);
}

You will need to specify this event name for the OnExcelAfterFormat property of the EntityGridView.  This method could also be used with a standard Gridview just prior to any other export code.

One other thing that I found is that the gridview did not export the filtered results.  So, for this I added a piece of code to rebind the search parameters.

On Page_Load when IsPostback = true

//if export link clicked

if (Request.Params.Get("__EVENTTARGET").Contains("lnkExport"))
{
     //make sure to rebind search params
     GridViewSearchPanel.DataBind();
}

Hope someone else finds this helpful!

Friday, October 2, 2009

Sharepoint uses SSL behind the scenes

Here's another tidbit that I wasn't aware of. We have been having issues getting Search to function on one of our WFE/query servers. It appeared to be configured exactly as the other, but continued to show Error on Search Administration page. After an upgrade to SP2, we saw a different error message for this server any time we tried to activate MOSS Search.

Unable to connect to *SERVER* for application SharedServicesProvider. This error might occur if the server is not responding to client requests, the firewall or proxy configuration is preventing the server from being contacted, or the search administration Web service is not running on the server.

It turns out, that SharePoint partly uses SSL name resolution in the background between farm servers. So, if the following conditions are true and you still can't get Search to function properly on one of your query servers you may want to take a look at this. the self-issued certificate that is used by the Office Server Web Services can become corrupted

  • The server that is running Office SharePoint Server 2007 has the query role in a server farm.
  • The server farm was updated with Microsoft .NET Framework 3.5 Service Pack 1 (SP1).
  • The roles of the query server and the index server are not on the same server in the server farm.

After recreating the self-issued SSL certificate, the error went away. Hope it helps someone!

Thursday, August 6, 2009

Discovered a new feature: MOSS Definition Extraction

I recently came across something that I didn't know existed. MOSS displays something in the search results that says 'See what others are saying about '. This is called Definition Extraction and I found helpful info here... http://jopx.blogspot.com/2008/04/moss-search-feature-definition.html


..the Definition Extraction feature finds definitions for candidate terms and identifies acronyms and their expansions by examining the grammatical structure of sentences that have been indexed (for example, NASA, radar, modem, and so on). It is only available for English.

It does not allow configuration, but you can turn it off in the search core results webpart properties.

Always something new to learn....

Monday, July 13, 2009

Some Clarity on Sharepoint ACLs

Well, I finally got some info today from Microsoft that pointed me in the right direction. We've been struggling with the best approach for our team sites considering the many number of Sharepoint groups that we will have. The link below really cleared things up for me about how the ACLs work and confirmed my inclination to break the team sites into their own site collections primarily for these reasons:
Dedicated administration - Security is separate, so the site owners will only see the groups for their site and no need to break inheritance
· Individual quotas can be setup on site collections, not sub sites, so we can better manage the growth of the larger ones without affecting the smaller team sites
· Recycle bins can be setup for each site collections, so these can be managed individually.. If everyone shares a site collection, then they share the recycle bins storage size too.
· Site collections can be grouped into a single db, or split out for easier management, & backup restore if necessary..smaller team sites should be grouped together for optimal db performance- query paths are chosen based on data characteristics (small number or large sites / large number of small sites)

More Clarity on Sharepoint ACLs => http://blogs.msdn.com/jimmiet/archive/2009/06/06/acl-limitations.aspx

Friday, June 19, 2009

Maximum number of Sharepoint Groups per Site Collection

I would love to know if there is a hard limit on the number of Sharepoint Groups per site collection. I know about the 2000 view item limit, but what about total groups?

I have a situation where a team site will have document libraries for multiple locations, in my case over 500 locations each with their own document library. Each library needs to be secured separately so that the location can only see their own info. We have AD groups for each location which we have added to Sharepoint Groups with permissions (per best practices recommendations), but what happens when we have several team sites and each one needs these location libraries?

We currently have all team sites in a separate (collaboration) site collection so we can share info across sites if needed. We have to break permission inheritence on each library to handle the individual security needs. We also want our locations to go to their 'My Teams' page which shows all subsites that they have access to. Future plans are to create separate (publishing site collection) sites for each location, where corporate groups can post specific info to the location site.


I would appreciate any advice (if anyone is reading). :)

Monday, June 8, 2009

KinderCamp here we come!!

Well, my son turned 5 in March and today is his first day in KinderCamp....woohooo! This is a transitional program to help him get prepared for Kindergarten. He has been in daycare since he was 2 when I decided to return to work. He already knows his alphabet; he can count to 100 (no, really he can) and he can write his name. I'm so proud of him, but it is so hard watching him get older. I just wish he could stay little as I'm sure most mothers do. He loves learning new things and playing with other kids so I know he will have a BLAST!

I hate to think of anyone spending more hours in a day with my son than me, but that is the daily struggle of trying to manage work and family.

They can't stay little forever. :)

Friday, April 24, 2009

These days it's all Sharepoint

I've spent the last 2 days & today attending a virtual conference from the comforts of home hosted by SSWUG.org. It has been the best $125 spent for training and it saved our company's budget. Hi-def streaming video with live chat, Q&A, and twitter feeds ... what more could I want!

I would definitely recommend this training and hope to attend future sessions. Check out http://www.sswug.org/ for more; it's more than just databases. :)