Reputation: 1844
I am looking for some code snippet which will render a gridview into <div>
instead of table.
Anyone can help me on this?
I need to draw a graph like the one I have attached and need some features like select the graph area with mouse and provide copy paste operation.
Upvotes: 5
Views: 5793
Reputation: 5179
I think you should use the ListView control introduced along with DotNet framework 3.5.
The ListView is a template driven control which means that it will not render anything by default. By default, the developer must completely specify the HTML he/she wants to render in the form of templates (should specify the HTML that should be rendered within the LayoutTemplate ).
See the code project url below to get implementation details..
http://www.codeproject.com/KB/webforms/CompleteListView.aspx
Also refer the following msdn video,
http://www.asp.net/aspnet-35/videos/the-listview-control
UPDATE: Since your project is using DotNet Framework 2.0 you should use a Repeater server control to acheive this
The Repeater control has no built-in layout or styles; you must explicitly declare all HTML layout, formatting, and style tags within the control's templates.
But paging,sorting etc will be a bit difficult using Repeater. The ListView is an updated version of Repeater with the mentioned functionalities as well..
Hope this helps you..
Upvotes: 3
Reputation: 35822
You can create your CustomGridView which inherits from GridView, and there, you can override Render method to loop through rows and generate any type of HTML you want. But the best way is to use ListView as @Harun said.
Upvotes: 0