Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 29, 2012 02:21 AM by TFA
Jul 04, 2011 07:27 AM|LINK
Bit of a problem that I cant get my head around.
I have on my page a div that has a fixed width and height. Inside the div I have a table, 2 rows, 1 column. I need to get from my Access database an image which is to be displayed in the tables 1st row (and sized to fit) and get some text which is to be
displayed in the tables 2nd row (label or textbox which i think i can do). At the moment the image is stored in the DB, i know that this isnt good practice but need to do it for time being before i move to storing just the url
Any help guys?
Jul 04, 2011 07:50 AM|LINK
good approch is creating separate image handler file .aspx, .ashx etc.
which takes imageid as parameter and return image as response object...
now, u can call this handler file as imageurl of image whenever u want to display image...
read this link for more details
u can set fixed height and width of <asp:image ... > control to restrict size of image being displayed on page...
hope this helps...
Jul 06, 2011 06:59 AM|LINK
Hi, thanks for the reply. Yes I can see how that works. I have had to change this slightly now, instead of 1 column, i need 2 (still 2 rows) col 1 row 1 needs image 1 col 2 row 1 needs image 2. Is this possible in gridview?
If i can bind image to img control and use a dynamic table i should be able to display all the images i need in the table?
Jul 06, 2011 07:26 AM|LINK
sorry, that wasnt very clear, here is some code to show how i need this layout...
<div id =content>
so img1 and img2 as well as txt1 and txt2 is pulled from Access DB. If I then had img 3 / 4 etc, they would appear on another table row.
Can a gridview do this?
Jul 06, 2011 08:46 AM|LINK
for the scenario explained by you... repeater is best suited control instead of grid.
if u have data in the format
img1 img2 txt1 txt2
img3 img4 txt3 txt4
in single row then try to use repeater control like this
<asp:Repeater ID="rptImagea" runat="server" >
<asp:image id="img1" runat="server">
<asp:image id="img2" runat="server"/>
<asp:label id="lbl1" runat="server"/>
<asp:label id="lbl2" runat="server"/>
Jul 06, 2011 09:07 AM|LINK
yes that seems more like it, but how do i populate it all from DB (images)
Jul 06, 2011 09:09 AM|LINK
also, my data is more...
img 1 img 2
txt1 txt 2
img 3 img 4
txt 3 txt 4
Jul 06, 2011 11:27 AM|LINK
if your getting data from database in following format
image1col image2col text1col text1col
image1 image2 text1 text2
image3 image4 text3 text4
then use repeater control as posted earlier... then
u have to retrive this data in dataset and set datasource of repeater like this
rptList.DataSource = ds;
all records from dataset will be displayed in template format we have set for repeater... for more info about using repeater control read this
Jul 06, 2011 02:38 PM|LINK
ah I see, the data in database is stored like this..
client_id, img, txt
so, if i had 2 rows in the data base i need it to appear on screen as..
img client_id1 img client_id2
txt c_id1 txt c_id2
does that make any sense?
Jul 06, 2011 02:40 PM|LINK