Pat’s .Net and Sharepoint Blog
In the Microsoft Sharepoint and .Net Trenches

Cascading DropDownList Custom Field Control

May 28th, 2008 . by <Patrick/>

After reading the DataCogs article on Sharepoint – Cascading Drop Down Lists I was inspired to take the challenge and modify the code to allow for an infinite number of cascading drop downs. I learned alot from the article, and I would highly reccomend anyone trying to create their own custom fields in Sharepoint to read it. The current code has a parent child relationship however you cannot include a grandchild dropdown.

In my humble solution, I have a drop down of continents, then a related drop down for countries and then a third dropdown with the related cities.

Continents

I created three lists: 

Continents

Countries
Countries

Cities

Cities

Cities

Then I created a new list where I add the three custom field type Cascading DropDown Fields to the list

Add Field

 country

 city

I added three new fields to the Cascading DropDown List Details section.

Name - the name of the field this should be a unique name to identify the field

Parent Name - name of the parent DropDown list control if there is one

Child Name - name of the child DropDown list control if there is one

The first custom field I added was the Continent and named it MyContinent for a
lack of a better name and I set the child to be MyCountry

The second custom field I added was the Country and named it MyCountry and added
MyContinent as the parent and MyCity as the child

The third custome field I added was the City and named it MyCity and added MyCountry
as the parent and left the child blank

Once my list was configured, I was on my way to the races.

The code available for download below is part of a Sharepoint solution.

In order to install it on your Sharepoint installation open up a command prompt,
navigate to the Solution folder wherever you unzipped the code to and run the Install.bat
file. I have also included an Uninstall.bat file. I haven’t quite had enough
time yet to get it to work as a feature but I plan to in the weeks ahead. Before running the solution make sure you have the makecab.exe utility. The Microsoft Cabinet Software Development Kit can be downloaded here.

Download code

For references on how to package up solutions the following are good articles to read:

Patrick Tisseghem’s Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 

Scot Hillier’s What’s Your Process for Developing SharePoint Features and Solutions? 

 

 

Read the rest of this entry »


SuperGrid

May 27th, 2008 . by <Patrick/>

Extending the GridView Control The SuperGrid control is an extended version of the ASP.Net GridView Control with some extra features. These features include the following:

  • An option to create a checkbox column and you can use the selectedIndexes property to obtain the selected values
  • A sorting indicator up/down
  • An automatic row count ie 1-10 of 200
  • Custom navigation
  • Row highlighting of any selected rows

I have included a Visual Studio 2005 Solution below along with a SQL Server database backup file that you can restore. I used the code from Dino Esposito’s wonder ful article in MSDN Magazine Extending the GridView Control as a starting point.

The solution includes two projects the SuperGrid which is basically the control and a little web application that makes use of the SuperGrid. The SuperGridSampleApp project includes a folder named db and this folder contains the database backup file called Customers.bak. The project also contains a folder named bll and it is an example on how I would typically create a business layer. I am curious about what other developers think about this technique of building a business layer.

Here is a screenshot of what it looks like:

SuperGrid

Click here to download a zip file with the code


Adding Sharepoint Intellisence to Visual Studio 2005

May 26th, 2008 . by <Patrick/>

Instead of adding the Sharepoint XML schema one file at a time to create your feature.xml files and element manifest files you can also add it to the Visual Studio XML schema cache. Every time Visual Studio loads, it loads the schemas defined in the XML schema cache automatically. 

Steps :

Navigate to:
c:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

Create a new XML file called Sharepoint.xml

Add the following code to the file:
<SchemaCatalog xmlns=”http://schemas.microsoft.com/xsd/catalog”>
  <Schema href=”file://%ProgramFiles%/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd” targetNamespace=”http://schemas.microsoft.com/sharepoint/” />
</SchemaCatalog>

Save the file If Visual Studio is already open close it then re-open it. This will reload all the schemas files including the one you just added

Now try creating a new feature.xml file

Specify the sharepoint namespace for the feature.xml file

XML Schema 

Now the intellisense should work!

 XML Schema


Where did my solution go in Visual Studio 2005!?

May 20th, 2008 . by <Patrick/>

Not sure if you’ve had this problem but sometimes in Visual Studio 2005 I lose the solution in solution explorer. To fix this problem go into Tools -> Options -> (Make sure Show all settings is checked) Projects and Solutions -> General and make sure that the “Always show Solution” is checked.

 Show Solution