Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Creating A Form WebPart in C#

  Asked By: Stella    Date: Apr 15    Category: Sharepoint    Views: 2749

I'm fairly new to both C# and SharePoint development. And I believe I
have a simple question that wont take much time, I've just had no good
luck trying to find a simple reference for it.

What I have right now is a WebPart that displays a lists field
names/values from a query in a table. And what I'm wanting to do is
have a few fields at the top that are text and/or dropdowns of
filterable values. Then those post back to the page and how I can have
those values in variables in my webpart.



5 Answers Found

Answer #1    Answered By: Naimish Ranganekar     Answered On: Apr 15

Do you want them at the top  of the webpart  or the top of the page? If
you want them at the top of the page  I would put them in a separate
webpart, put that on the page outside a Webpart zone and then use a
connection to pass the values. As to the filtering I normally do that
by putting the data in a dataview and using the row filter capabilities
of that. Then bind the controls to the Dataview.

If that's not clear give us a little more info and I'll try to provide a
bit more direct answer.

Answer #2    Answered By: Caleb Gordon     Answered On: Apr 15

Do you have an example or reference  that you can share? I wasn't aware that
you could put webparts on a page  outside of a webpart  zone.

Answer #3    Answered By: Christie Carlson     Answered On: Apr 15

They have to be webparts based on the Microsoft.SharePoint object model
rather than System.Web and you have to do it with SharePoint Designer,
but yest you can embed a SharePoint 2007 webpart  directly on the page.

Answer #4    Answered By: Dorothy Farmer     Answered On: Apr 15

Thanks for replying, and sorry I have been sick or I would have
responded quicker.

What I'm hoping for is at the top  of the webpart. And would prefer not
to use dataview, but use my own display code. All my code does is
grabs the field/column values  out of a list with SP Query.

To give reason - I am running on just WSS3 and have a document list
with like 600 documents in it. And those who are using this library
want to be able do a search by name for these documents, and possibly
filter three other columns.

But I'm so unfamiliar with C# I don't even know how to create a form
that will post  back to the page, then how to get those values in that
webpart. I'm open to other suggestions, but really would like to
display my own table  so I have control on look and simplicity.. But I
guess all I really am looking for is the code to post a form  and grab
its values in a webpart.

Answer #5    Answered By: Jacklyn Burnett     Answered On: Apr 15

First, you don't have to build webparts in C#. You can build them in VB
just as well. You just can't use Microsoft's VSeWSS templates to do it
because they don't come in a VB version. Second, I wouldn't create a
form outside the webpart  to feed filter values  in. I would either put
it in the same webpart or in a separate webpart. Third, creating  a
webpart is pretty much like creating a webpage, except you don't get a
drag and drop design surface. Use a CreateChildControls method to
instantiate the child controls and a RenderContents method to control
how they will render on the page.

Didn't find what you were looking for? Find more on Creating A Form WebPart in C# Or get search suggestion and latest updates.