I need to develop a custom Web Part in C# to show the name and url of the list marching the specified type.
The idea being that the user will choose the ‘list type’ from a ‘checkbox list’ to select. The checkbox list contain ‘Event’, ‘Task’ and ‘Custom List’.
Since this is a checkbox list, the user will be able to select more than 1 list type. So for example, if the user selects ‘Event’ and ‘Custom List’, I am supposed to show them the name of all the Custom & Event List’s that are in the site, regardless of whether the list’s contain any item. For each list I need to supply a link (url) to the matching lists.
Any ideas on how to do this?
Thanks for the question. First and foremost I’d like to bring up the idea of not using C# for your webpart. Farm Solutions are no longer the “best practice” way to be building webparts in your SharePoint environment. For more information click here .
If you really need a webpart, I would look into the SharePoint-Add In Model and use JavaScript to do this. However, you should should use the REST APIs to do all of this work (whether in C# or JavaScript).
Please see the MSDN Rest API . In there you will see how to interact with the lists (the returned queries will have the template type).
Now, if you wish to go a different way… you would use SharePoint Search (Content Search Webpart (if you have licensing)). You could easily query ALL of the lists in your site using a simple REST Query using the Search API found here. You can find examples of using “Content_Class” to query your lists and by your templates here.
Instead WebPart, if you create Windows Application with Cloud Account/Windows Account credential, the data will be displayed on GridView and same export to excel. If you looking to have on SharePoint then use REST API or JSOM script with Content Editor Web Part using HTML table display.