![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
OK, so I now have a gridview on my page. Because my data isn't stored in such a way that I can bind the grid directly to the database, I am creating a DataTable in code, running some procedures to fill this with data in the right format from the database, all processed accordingly, then binding the DataTable to the grid. This works, but newline characters (i.e. "\n") don't work. I also tried putting them in as <br> but no joy. Doing some googling, I have read that I need to use "TemplateFields" on the grid. If I go to the Column Editor for my grid, I don't have any columns to edit (they are generated at runtime by the binding to my datatable I guess) so I can't convert them to template ones. Any thoughts? I tried adding some columns and setting the AutoGenerateColumns to false, but then my data doesn't appear so I must be missing some other step...! |
#3
| |||
| |||
|
|
On 14 Dec, 15:43, "JamesB" <jam... (AT) somewhere (DOT) com.net.com.net> wrote: OK, so I now have a gridview on my page. Because my data isn't stored in such a way that I can bind the grid directly to the database, I am creating a DataTable in code, running some procedures to fill this with data in the right format from the database, all processed accordingly, then binding the DataTable to the grid. This works, but newline characters (i.e. "\n") don't work. I also tried putting them in as <br> but no joy. Doing some googling, I have read that I need to use "TemplateFields" on the grid. If I go to the Column Editor for my grid, I don't have any columns to edit (they are generated at runtime by the binding to my datatable I guess) so I can't convert them to template ones. Any thoughts? I tried adding some columns and setting the AutoGenerateColumns to false, but then my data doesn't appear so I must be missing some other step...! Hi Jeremy In the circumstances you describe the best alternative is to use an ObjectDataSource linked to a class file (placed in the App_Code folder) containing your data construction code in the form of a public function that returns the resulting DataTable, and then set the ObjectDataSource as the DataSourceID property for the GridView control. The designer wizard for setting up templated databound controls will not automatically list the column names, but if template columns are added manually, and the source column names typed in correctly, it will work Ok at run time. Also, if automatic column generation is set to true, that should work Ok at run time as well. There are many other steps to setting this up fully which are too numerous to describe here, but if you search the help files you should find what you need. HTH Phil |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |