billsecond
billsecond

Reputation: 612

SharePoint List Control in a custom WebPart and C#

All,

I am trying to replace a DataGrid that I have with the SPList control in Visual Studio 2010 C#, but where does this control live, and how can I use it?

Are there examples?

Bill.

Upvotes: 0

Views: 6792

Answers (3)

Colin
Colin

Reputation: 10638

There's a whole bunch of options:

  • Use sharepoint designer to "design" your webpart (for data usually based on the DataFormWebPart or, in SP2010, the XsltListViewWebPart). When your done, export the .webpart file and import it into sharepoint.

  • In Visual Studio 2010, create a visual webpart, and use the standard ASP.NET ListView or GridView on it.

  • In Visual Studio, program a webpart and override the CreateChildControls method and add an SPGridView, ListViewWebPart, etc. etc. through code.

Upvotes: 0

Tom Vervoort
Tom Vervoort

Reputation: 5108

Maybe you mean the SPGridView control. There's an example for SharePoint 2007 here: http://blogs.msdn.com/b/powlo/archive/2007/02/25/displaying-custom-data-through-sharepoint-lists-using-spgridview-and-spmenufield.aspx

I haven't used it in SP2010 yet, but I suppose it's still there and works more or less the same.

Upvotes: 1

Madhur Ahuja
Madhur Ahuja

Reputation: 22661

There is no SPList Control, SPList is a class.

What you are talking about is ListViewWebPart , a web Part which is used to display lists. This is used by SharePoint.

You can use this dynamically as described here:
http://weblogs.asp.net/jan/archive/2005/06/22/414283.aspx

Upvotes: 2

Related Questions