问题
I currently have an ASP.NET script for a TV guide which displays the data from the database properly in a tabl, as mentioned at http://www.15seconds.com/issue/050407.htm and it works well.
The code for getting the MySQL is the same as that of the link above, except for username and password of MySQL, and the database as well.
Example data:
06:00 Breakfast News
06:45 The Force
07:45 House M.D.
08:15 Police Stop!
09:15 Showbiz Gossip
09:45 Quantum Leap
10:45 Harry Hill's TV Burp
However, data displays in a tabular format, with borders, and the times should display as:
6:00am 6:45am
etc.
but I'm currently trying to create an ASP.NET pagination like this for programme/episode guide and air times:
http://library.digiguide.tv/lib/programmenextshowing/21260
Although that's classic ASP in the example site, mine is ASP.NET.
I'm trying to emulate their style of pagination, with MySQL, but can't seem to get it to work - PHP is no problem, however, the actual webhost for this TV website doesn't support PHP, only ASP.NET. I normally use aspdotnet with modaspdotnet on Apache, but am going to be using it on a webhost that supports ASP.NET only [but includes MySQL as well].
These are my database fields from one of my databases, quantumleapguide
programme channel episode (should be blank if no episode, have episode name "in quote marks" if episode) seriesno episodeno
and should display as:
Quantum Leap showing on TV Channel 1 23rd June - 6:25pm "Test Episode"
Series 1, episode 4. Set Reminder
Quantum Leap showing on TV Channel 1 24th June - 1:25am
Set Reminder
How would I get this to work as an ASP.NET script - I did try some of them off Google, and they were not entirely successful, the data displayed was as a table with borders.
This is the code I expect it to render in the browser (apologies, will have to scroll to see how it should work):
<tr><td><b><a href="quantumleap.aspx">Quantum Leap</a></b></td><td>showing on <a href="channel/1.aspx><i>Channel 1</i></a></td><td>23rd June - 6:25pm</td><td><b>"<a href="/library/episode/1.aspx">Test</a>"</b><br>Series 1, episode 4.</td></tr>
<tr><td><b><a href="quantumleap.aspx">Quantum Leap</a></b></td><td>showing on <a href="channel/1.aspx><i>Channel 1</i></a></td><td>24th June - 1:25am</td><td><b>"<a href="/library/episodes/1.aspx">Test</a>"</b></td></tr>
<tr><td><b><a href="quantumleap.aspx">Quantum Leap</a></b></td><td>showing on <a href="channel/1.aspx><i>Channel 1</i></a></td><td>24th June - 11:50am</td><td> </td></tr>
What would you suggest as a way to fix this and have it working well, since previous attempts at ASP.NET pagination haven't worked?
Any and all help appreciated.
回答1:
I think what you're asking is how to approach creating a programming guide in ASP.NET.
To accomplish what they have on the digiguide.tv link using ASP.NET, I would retrieve your data with MySQL, put it in a valid datasource, and bind that datasource to a ListView or similar control. This is a good tutorial. Inside your for the ListView, you would create that table that you shared the code for.
Then for the paging, ASP.NET has a control called DataPager, which allows you to easily accomplish server side paging for a targeted listview.
回答2:
You do know that you can write ASP.NET code exactly like classic ASP or PHP, right? You don't have to use all those ASP.NET web server controls, you can simply output your own HTML directly, and put the logic in <% ... %> and <%= ... %> tags.
(In fact you can sometimes change a classic ASP page to an ASP.NET one just by adding a couple of header lines and changing the extension to .aspx!)
It's what I prefer to do, since I like to have 100% control over the HTML output, and you don't have that using server controls. Personally, I love coding in ASP.NET but I hate the server controls!
Just write your page the same way you would in PHP (except using C# or whatever .NET language you prefer for the actual code), and it should be easy!
来源:https://stackoverflow.com/questions/6325178/asp-net-pagination-getting-it-to-work-properly