Link to home
Start Free TrialLog in
Avatar of VCyrus
VCyrusFlag for United Kingdom of Great Britain and Northern Ireland

asked on

how do i integrate ListView with ASP.net MVC 2 ???

hi i want to integrate listview with mvc application that i have .. i dont know if it is possible since the Listview is a Server Side component. actually i did found a post about it here but i didnt work with me i dont know what is wrong
Avatar of tbsgadi
tbsgadi
Flag of Israel image

Using server side controls in MVC negates the point of MVC - clear separation of concerns. Therefore it is definately not a recommended approach.

I tend to simply code the table in my view

<table>
<% foreach(var item in Model.ListOfItems) { %>
<tr>
  <td><%= item.MyProperty %></td>
  <td><%= item.AnotherProperty %></td>
</tr>
<% } %>
</table>

However there are a number of MVC controls which use HTML helper extension methods, including in the MVC contrib project.
Avatar of turkserdar
turkserdar

just want to add james comment. if you create a custom View make sure to use IEnumerable to use foreach loop. MVC great for performance and expandibility.
Avatar of VCyrus

ASKER

hi all ,,
thanks for replying ..

@tbsgadi: the controls u pointed me at is a whole new story i want simpler solution to work listview in my project not to add new control .. but thanks anyway .. great tool over there .

@jamesbaile: this is basic thing u showed i know how to do that ,, and by the way it is better to html.encode ( item.property ) ,

i want to use listview so i can get use of its features like sorting and paging .

Yes. I agree about the Html.Encoding bit - my examples are not production grade, just examples to demonstrate the principles.

If you are doing MVC then I'd really caution against using standard ASP.NET controls in your views. Just becase it's possible does not mean you should do it. If you want to use ListViews and that's the best thing for your application then you should use standard ASP.NET. However there are many options for displaying tabular data in grids - in one application I am developing I am using Yahoo YUI DataTables hooked up to MVC controllers. The grids are 100% ajax and handle sorting, paging etc.


Avatar of VCyrus

ASKER

thnx jamesbaile  for replying  .. i am not criticizing ur code here or anything ..
if u can demontrate that pls cuz i am new to this ajax stuff ..or where i can find some basic or advanced tutorial ... i really appreciate ur effort to help
ASKER CERTIFIED SOLUTION
Avatar of jamesbaile
jamesbaile
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VCyrus

ASKER

sorry i have not replied  but i have been so busy test stuff out .. i figured out that ExtJs Framework is the best( for those who have experience with JavaScript) also better than jquery...  nice Framework from yahoo as pointed jamesbaile ..
but after all i think i will stick to Telerik ASP.net web controls ... it is much easier to manage the code and i wont be disturbe with so much JavaScript Code.