Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting asp.net table to DataGrid 1

Status
Not open for further replies.

mais123

Programmer
Dec 26, 2007
36
US
Hi, I have a page that uses asp.net Table (<asp:Table>) to display data. In code it loops through dataset and creates the table. It also appends JS attributes while it does it.
I need to use DataGrid instead now. Creating Datatable instead of generating table is not hard, but we cant add attributes to DataRow's and DataCell's, liek we do for TableCell. And there is a complicated logic for attributes, which is why it makes it hard to move it all to onItemBound event.
Is there any way I can still use Table and somehow bind it, with all its attributes to the DataGrid? Maybe create a class out of table?

Thansk for any help
 
we cant add attributes to DataRow's and DataCell's, liek we do for TableCell
No, you can't but that is because DataRow's and DataCells are part of the data source not the data control. Instead, you should apply any logic to the cell within the DataGrid row.

And there is a complicated logic for attributes, which is why it makes it hard to move it all to onItemBound event.
Well this is the best place for this logic, so I'd suggest finding a way of making this complicated method easier to implement and add it in this event.



-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Is there any way to create DataTable from Table(of cource not including attributes)? This would simplify conversion a bit I think

Thanks
 
For example, adding TableRow to DataTable does not give an error. But what does it produce?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top