Database has 5 columns: Section, Author, Title, Link, Bibiography
Website:
Section
Author, Title (linked), Bibiography
...
Author...
Section
Author...
Make sense?
This would be very easy in asp, but I haven't quite gotten the grasp of .netSuggestion: Forget ASP. Yeah it stinks to start over, but it's easier that way.
the 'dot net way':
Grab the data into a data set. Check out theTutorials (linked above). There are also a ton of other sites out there for accessing data from a database with .NET. Search for '.NET + Access + DataSet'.
Once you have it in a DataSet object the rest is sooooo easy. Just setup a repeater object on the page. Then an 'item template' and define how you want each item to look like. Lastly add a seperator template if you want something between records. Finally in the code section do MyRepeater.DataSource = MyDataSet.Tables(0) *your data, then MyRepeater.DataBind() and you'll be all set. If you want tabular data without too crazy of formatting, check out the DataGrid. If you just want to list the results in columns you do the DataSource line from above (except you use a DataGrid object) and the DataBind method call. The rest is automagic.
If you need help with the data access, check out the Access forum in the Data Discussions section.
-Ryan
You can use a Repeater, DataList, or DataGrid for this purpose. This tutorial might be helpful:Binding to Data Display Controls. See also the Tutorials section of this site (in particularData Access and Customization). I think a DataList might suit your purposes pretty well, or a Repeater if you need more control (but also requires more coding).
Terri
thanks for the quick responces...
I looked up how to use the repeater control and it seems like this is what I'm looking for. Is the best way to group all of the same sections together to make an if statment? Is that legal within a repeater? Here's what a sample database looks like
General, Blah, Blah
General, Blah2...
Science, Blah3...
Science, Blah4...
I'd like it to:
General
blah
blah2
Science
blah3
blah4
Thanks for all your help
I think you want to put a Order By clause in your SQL Query.
Select Section, Author, Title, Link, Bibiography from MyDB
Order By Section, Author DESC
This will return
General, bob, bobs book, xxx, xxxx
General, sarah, sarahs book, xxx, xxxx
General, tim, tims book, xxx, xxxx
Science, joe, joes book, xxx, xxx
It first sorts Section alphabetically and then within all matching sections it then sorts on the author.
0 comments:
Post a Comment