Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there an option how to obtain the list view rendered html from code?

For example I have an item (for example task ct) and i would like to obtain html rendered (on server side) if this item will be displayed in list view. I know it sounds stupid but ... I would like to know if this is even possible

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Ivan,

I don't know what exactly you are trying to do...

But you can use SPGridView, a server-side control which behaves just as List View control...

Some samples for using SPGridView control

If you want to use the same look and feel, you can use IE Developer Tools to identify the classes used for the table and use in your code... Or Chrome Inspect Element or FireBug will be helpful...

I hope this helps

share|improve this answer
    
thanks! I overlooked this class! I will go this way –  Ivan Feb 24 '13 at 14:50

It does not sound stupid to me. Recently we used this solution to get number of list items in a view with grouping.

Anyway, there is a SPView.RenderAsHtml() for this purpose.

share|improve this answer
    
thanks, i know about that, we used for rendering on client side, this is great. however i need to dynamically render the view. therefore i probably prefer the spgridview, but thanks! –  Ivan Feb 24 '13 at 14:45

I'm not clear exactly what you're trying to do, but if you're looking more at the item level than the view level, there's SPField.GetFieldValueAsHtml(object value) which you could use to get formatted values for individual fields in a list item (There's also SPListItem.GetFormattedValue(string fieldname) - not sure what the difference is there).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.