Solved

Add button to web part in WSS3

Posted on 2011-02-20
5
621 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

864 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

21 Experts available now in Live!

Get 1:1 Help Now