473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

asp.net 2.0 data access driving a novice nuts... inputs are more than welcome

Hello all,
Before I start I'd like to point out that I am a complete novice when
it comes to asp.net - My background is in network and operating
systems, and although I have been doing a bit of hobby programming in
vb.net and web programming in asp/vbscript in the past, I am pretty
much a beginner at asp.net.

What I'm trying to do, is to take the "PersonalHomePage" starter kit
that MS supplies with VS2005 and tweak it a bit, to make it suitable
for my own homepage. The PersonalHomePage starter kit stores all the
photos for its photo album inside a SQL Database, and I'm gonna use a
regular file/folder approach instead, using an Access database to hold
to relationship between albums and photos. So to the problem:

The albums.aspx page shows all my albums, with a link for each of them.
Also, the page shows one photo for each album, so that the visitor can
see an example of photos the particular album holds.

To list the albums is easy enough - I use a DataList and an
AccessDataSource that queries all my albums. The DataList automatically
repeats itself the number of records in the DB, and I can use the <%
#Eval("AlbumName") %> tag to display the Name and ID of each album, as
well as generate a link for taking the visitor to the selected album
(something like albums.aspx?id=<%# Eval("AlbumID") %> or thereabouts)

Here's the tricky one: I'd like to have a second AccessDataSource which
accepts AlbumID as a parameter and generates the URL for the photo. In
my "Photos" table I already have a field for ImageURL, so displaying
photo for each of the albums should simply be a matter of getting this
ImageURL into the "img src=" part of the code.

However:
-I am not allowed to have more than one AccessDatasources for a
DataList, so I can't do an "Eval" on more than one datasource per
DataList.

-I could create the datasource for the image in the code-behind file
inside a function which accepts AlbumID as a parameter and return a
ImageURL to the aspx page. However, this would give me the code
(assuming that the function is named GetImageUrl):

img src=<%GetImageUrl( <%# Eval ("AlbumID") %> ) %>

which of course is not allowed, as it is two "nested" scripts.

I know I could do this by constructing a second page called
imagehandler.aspx or whatever, that would take the album as a parameter
and return the image as a stream, but I was hoping to avoid using
advanced stuff like streams here (small steps etc..).

The things that are driving me nuts are:
1.I know how to do this with Dreamweaver version ca 2001 using regular
asp, here I was able to parameterize pretty much whatever I wanted
without using server controls, which I guess in a way was more of a
hassle, but at least I had full control over the entire page.

2. When looking at documentation (both in msdn and in books24x7.com,
whenever I look for "asp.net 2.0 data access" all I get are the "Build
data-driven pages witout a single line of code!". I gotta say, I'm more
interested in solid examples than making software without coding :-)

Of course, I know that this is beta stuff, and as such, not fully
documented. And when posting this, one of you asp.net experts are
probable going to make me eat my words by showing me how I can achieve
what I want here with only two lines of code, but still: I can't help
but feel that anything that requires me to "pop the hood" and go beyond
the wizard-driven stuff is getting harder and harder - not easier and
easier...

Any comments or helpful hints are deeply appreciated. Sorry for making
you read all this :-)

kind regards,
Trond Hindenes
Novice asp.net programmer
Norway

Nov 19 '05 #1
4 1630

tr***@hindenes.com wrote:
Hello all,
Before I start I'd like to point out that I am a complete novice when
it comes to asp.net - My background is in network and operating
systems, and although I have been doing a bit of hobby programming in
vb.net and web programming in asp/vbscript in the past, I am pretty
much a beginner at asp.net.

What I'm trying to do, is to take the "PersonalHomePage" starter kit
that MS supplies with VS2005 and tweak it a bit, to make it suitable
for my own homepage. The PersonalHomePage starter kit stores all the
photos for its photo album inside a SQL Database, and I'm gonna use a
regular file/folder approach instead, using an Access database to hold
to relationship between albums and photos. So to the problem:

The albums.aspx page shows all my albums, with a link for each of them.
Also, the page shows one photo for each album, so that the visitor can
see an example of photos the particular album holds.

To list the albums is easy enough - I use a DataList and an
AccessDataSource that queries all my albums. The DataList automatically
repeats itself the number of records in the DB, and I can use the <%
#Eval("AlbumName") %> tag to display the Name and ID of each album, as
well as generate a link for taking the visitor to the selected album
(something like albums.aspx?id=<%# Eval("AlbumID") %> or thereabouts)

Here's the tricky one: I'd like to have a second AccessDataSource which
accepts AlbumID as a parameter and generates the URL for the photo. In
my "Photos" table I already have a field for ImageURL, so displaying
photo for each of the albums should simply be a matter of getting this
ImageURL into the "img src=" part of the code.

However:
-I am not allowed to have more than one AccessDatasources for a
DataList, so I can't do an "Eval" on more than one datasource per
DataList.

-I could create the datasource for the image in the code-behind file
inside a function which accepts AlbumID as a parameter and return a
ImageURL to the aspx page. However, this would give me the code
(assuming that the function is named GetImageUrl):

img src=<%GetImageUrl( <%# Eval ("AlbumID") %> ) %>

which of course is not allowed, as it is two "nested" scripts.

I know I could do this by constructing a second page called
imagehandler.aspx or whatever, that would take the album as a parameter
and return the image as a stream, but I was hoping to avoid using
advanced stuff like streams here (small steps etc..).

The things that are driving me nuts are:
1.I know how to do this with Dreamweaver version ca 2001 using regular
asp, here I was able to parameterize pretty much whatever I wanted
without using server controls, which I guess in a way was more of a
hassle, but at least I had full control over the entire page.

2. When looking at documentation (both in msdn and in books24x7.com,
whenever I look for "asp.net 2.0 data access" all I get are the "Build
data-driven pages witout a single line of code!". I gotta say, I'm more
interested in solid examples than making software without coding :-)

Of course, I know that this is beta stuff, and as such, not fully
documented. And when posting this, one of you asp.net experts are
probable going to make me eat my words by showing me how I can achieve
what I want here with only two lines of code, but still: I can't help
but feel that anything that requires me to "pop the hood" and go beyond
the wizard-driven stuff is getting harder and harder - not easier and
easier...

Any comments or helpful hints are deeply appreciated. Sorry for making
you read all this :-)

kind regards,
Trond Hindenes
Novice asp.net programmer
Norway


Nov 19 '05 #2
Try using a sql statement with joins to multiple tables.

Nov 19 '05 #3
no. Your list will have a text and value information and you want to
also get the image url [and contain it in the list]. You could do a
postback image url lookup after each user change event to the list.
Possibly pull all three fields in inital db pull and put albumid/url
combination in viewstate for use when user list change event occurs.

If you want something easy, use a datagrid, which can have
visible=false columns to hide url.

-K

Nov 19 '05 #4
You should be able to do as many eval() statements, concatenated with a
'+' as you want.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SD | last post by:
Hi, This is driving me nuts, I have a table that stores notes regarding an operation in an IMAGE data type field in MS SQL Server 2000. I can read and write no problem using Access using the...
1
by: Darren Lew | last post by:
Hi there, I have this problem which is really driving me nuts for a couple of days. Glad if any help or suggestion is given Javascript will give me a pop-up error "Access is denied" when i try...
12
by: Marty | last post by:
It seems all of the sudden that user controls that contain images are referencing image sources relative to the document that I drop the control on. This obviously does not work beacuase the...
2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
2
by: Michael | last post by:
Hi Everyone, Please help me on this one. I have the following function: Public Sub SearchFor(ByRef mType As Module1.SearchForType, ByRef mValue As String) On Error GoTo Err_Handler Dim Proc As...
1
by: Ray Nimmo | last post by:
This is driving me nuts, been at it now for the last week, anyone any ideas on wher im going wrong? using a list box pipeLB and a date/time picker pDate, im trying to populate the list box with...
21
by: gurdz | last post by:
Does anyone know how to perform data validation in C? I have searched google for every possible result, and I either end up with data validation for C++ or nothing at all. I have also searched...
1
by: NHNeedsHelp | last post by:
Hi, about to go nuts - I have a master form with 3 control buttons, user picks 1 for Const. job, 2 for Envir job and 3 for Geo job. Each button opens a subform containing the project number from...
3
by: DuncanIdaho | last post by:
Hello experts IE 7.0.5730.11 Opera 9.27 Firefox 2.0.0.14 This problem only occurs in Opera and Firefox (amazing, IE does something right, or maybe not) Anyway, the problem is that when I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.