Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

web part with dropdown list

  Asked By: Tapasvi    Date: Feb 02    Category: Sharepoint    Views: 20633

I need to build a web part with a dropdown list in it. The dropdown list needs
to be populated from a list in the same site. I downloaded the smartpart, but it
doesn't seem to want to let me populate it from a list in MOSS. What am I doing



25 Answers Found

Answer #1    Answered By: Latrice Henson     Answered On: Feb 02

Can u give some more description or post the code?

Answer #2    Answered By: Nidhi Tiwary     Answered On: Feb 02

Depending on what you need to do, you could create a lookup field; that
render a dropdownlist filled with the contents of a list.

Answer #3    Answered By: Beatrice Serrano     Answered On: Feb 02

I need to populate  a dropdown  list with the a field from a SP list. Then I would
like to connect it to another web  part based on what it selected from the
dropdown list.

Answer #4    Answered By: Maya Lewis     Answered On: Feb 02

In SPD I have created a dropdown  listbox and attached it to a SP list. But how
do I use that in a web  part?!?

Answer #5    Answered By: Paola Mcmahon     Answered On: Feb 02

You have to write code to achieve it, if you are developing a custom web

Answer #6    Answered By: Justin Mckee     Answered On: Feb 02

Can you be more specific? It seems that the GUI tools have done the heavy
lifting, or at least I hope!

Answer #7    Answered By: Jared Bell     Answered On: Feb 02

If custom web  part is going to be your approach, then you will have to
create either a user control and host it in a web part, or just create a web
part by creating controls inside it dynamically through code.

Answer #8    Answered By: Bernice Puckett     Answered On: Feb 02

Well, I am trying to create a user control in SPD, and then add it to the
SmartPart, but apparently SPD doesn't add the codebehind file. And the SmartPart
can't pick up the user control without the codebehind. You'd think that if you
can create the control in SPD, that it wouldn't be that hard to somehow use it
in SP! It's like they show you the path to the Promised Land, then make you
wander in the desert for 40 years...

Answer #9    Answered By: Mackenzie Lewis     Answered On: Feb 02

That's what you get for complaining...............

Answer #10    Answered By: Kurt Gilbert     Answered On: Feb 02

The problem is that SPD can't add the code behind because any page or
control that is stored in the content database is prohibited from containing
server side code. If you had a code behind with code in it the code
wouldn't compile anyway if the control is stored in the content database.
To write any kind of server side code requires the use of Visual Studio.

Answer #11    Answered By: Jaya Deoghar     Answered On: Feb 02

Actually I think it is more from lack of faith than complaining.

Answer #12    Answered By: Candi Branch     Answered On: Feb 02

Well guess what? It appears that when I change the layout to dropdown  list, I
lose the ability to connect the web  parts! I'll keep at it today and see if I
can get it to work though.

Answer #13    Answered By: Jan Chen     Answered On: Feb 02

Okay. What are you really trying to do? Your original post says you want to show
in one ˜webpart" what is selected in another ˜webpart". How should it be
displayed? Are you trying to populate  a grid or something? What is your output
requirement and why are you doing it? There are too many questions unanswered
right now to give you a solution. I am a big fan of jQuery but it depends on
what you are trying to get to in the end...

Answer #14    Answered By: Britni Shepard     Answered On: Feb 02

Simply put, I am trying to create a dropdown  list. When an item from that list
is selected, the corresponding records for that item need to display in a web
part. You could think of it like a customer dropdown list  that feeds an invoice
web part.

Answer #15    Answered By: Girja Garg     Answered On: Feb 02

You can use a dataform web  part created in SPD and bound to the list  to do that.
Simply change the layout of the web part  to a dropdown  after you've bound it
to the data and then connect it to another dataform web part that has the data
you want to filter.

Answer #16    Answered By: Jarod Mathews     Answered On: Feb 02

Really? I didn't know that. I'm off to do that right now!

Answer #17    Answered By: Amanda Lewis     Answered On: Feb 02

Here's another question. How do I reference a SP list  from Visual Studio?

Answer #18    Answered By: Cassie Snyder     Answered On: Feb 02

Are you looking for some code like this?

if (SiteCollectionURL == null)
SiteCollectionURL = SPContext.Current.Web.Url;

SPSite refSite = new SPSite(SiteCollectionURL);
SPWeb refWeb = refSite.OpenWeb("/");

SPList refList = refWeb.Lists[myListName];

This is a web  page so the user can specify the URL in a QueryString
parameter; if they don't, I just use the current site  from the SPContext.

Answer #19    Answered By: Parijat Pathak     Answered On: Feb 02

And I will use any solution that gets a SP list  column into a dropdown  list
that I can then connect to another web  part! I've been back and forth with this
and still cannot figure a solution.

Answer #20    Answered By: Ella Sargent     Answered On: Feb 02

I have done this but it is fiddly. From memory, the steps using SharePoint
Designer are:

* Add a datasource control for the list  you want to use in the drop-down to the
page (you get this option in the datasources task pane)
* Add an ASP.NET dropdown  list control on the page
* Hook the dropdown list to the datasource control so it shows the desired
* Create a DataForm web  Part (aka data view) showing the list you want to filter
* Define a parameter on the dataform web part  to point to the dropdown list
* Set up the filter to use the parameter

SharePoint puts code on the page, so it's dynamic i.e. as soon as you select
from the drop-down, the page will be refreshed with the filtered data. The
downside is that it is not Ajax, so the whole page re-displays, so the
experience is not fast or seamless.

Answer #21    Answered By: Ahmad Johns     Answered On: Feb 02

I just tried this and get the error:Â "An unexpected error has occured"

And of course we can't debug it on SP2007!

Answer #22    Answered By: Roxanna Hendricks     Answered On: Feb 02

You can debug using Visual Studio :) Not so helpful here, I know...

Have you checked the SharePoint logs in the 12 hive? Usually when you get
an obscure server-side error like that in SharePoint, you can get some more
details in the SP logs or in the Windows Event Log.

Answer #23    Answered By: Stacia Guy     Answered On: Feb 02

I googled and figured out how to modify the web.config so I get a more
meaningful error.


Answer #24    Answered By: Kacy Bright     Answered On: Feb 02

I think I had something hosed with the data source or something on the page.
When I started with a clean page it worked fine!

Answer #25    Answered By: Ivette Burris     Answered On: Feb 02

Ah, good to know. Thanks for the tip, BTW; I didn't know about the
CallStack bit (just always turned off custom errors).

Didn't find what you were looking for? Find more on web part with dropdown list Or get search suggestion and latest updates.