Solved

Add button to web part in WSS3

Posted on 2011-02-20
5
622 Views
Last Modified: 2012-05-11
I want to customize a web part page in WSS3 to show contact list for three offices.

When i click first buttion, the content part show contact list of office 1;
When i click button 2, it show contact list of office 2;
When i click button 3, it show contact list of office 3;

Any idea how can i do this?
I am new to sharepoint.
Thanks a lot.

list.jpg
0
Comment
Question by:dickchan
5 Comments
 
LVL 7

Accepted Solution

by:
AlMothanaAlOmari earned 167 total points
ID: 34940848
0
 
LVL 14

Assisted Solution

by:KoenVosters
KoenVosters earned 166 total points
ID: 34941078
AlMothana your post is for SharePoint 2010.

DickChan I presume I can assume you have some development knowledge. In that case this link should point you in the right direction:
http://www.c-sharpcorner.com/UploadFile/sarav82/webpartlifecycle01102008061313AM/webpartlifecycle.aspx
0
 
LVL 3

Expert Comment

by:AndrewSkoraro
ID: 34946254
Where is the contacts data stored?  If its a list then I would just filer the list results using a caml query.  

Start by adding a required column named Office to your contacts list.  Make this a choice column and add your three offices as the list of choices.

Create the webpart in VS and add the three buttons.

Here is the code to filter the list and return the results as a DataTable.  Use the DataTable to bind to a grid or iterate through the SPListItemCollection directly if you wish to write out the results yourself.  If you use a grid or other bindable control you will need to limit the results to the required fields or you will end up with a lot of unnecessary output as it contains all columns from the list.

        public static DataTable GetContactsDataTable(string office)
        {
            DataTable ret = null;

            try
            {
                SPList contactsList = SPContext.Current.Web.Lists["Contacts"];
                SPQuery query = new SPQuery();
                query.Query = string.Format("<Query><Where><Eq><FieldRef Name='Office' /><Value Type='Choice'>{0}</Value></Eq></Where></Query>", office);
                               
                SPListItemCollection contactsListItems = contactsList.GetItems(query);

                ret = contactsListItems.GetDataTable();  
            }
            catch (Exception ex)
            {
                //Handle Exception
            }

            return ret;
        }


0
 

Author Comment

by:dickchan
ID: 34948957
Contacts data is stored in a word file. Each office on file.
Any web part can load the content of the word or PDF file directly?
0
 
LVL 3

Assisted Solution

by:AndrewSkoraro
AndrewSkoraro earned 167 total points
ID: 34955203
Is it possible to change the information to something that will work as a valid data source? Excel or SharePoint list?  
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint Designer 2013 4 61
Onedrive for business 3 46
.removeAttr() not working in my SharePoint JSOM code 8 61
SharePoint Designer 2010 - Format Item As Changed 2 28
Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now