Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add button to web part in WSS3

Posted on 2011-02-20
5
Medium Priority
?
626 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 7

Accepted Solution

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

Assisted Solution

by:KoenVosters
KoenVosters earned 664 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 668 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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