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
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?
mike7510uk
Member
716 Points
334 Posts
get image from database, resize and display
Jul 04, 2011 07:27 AM|LINK
Hi,
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?
Thanks
Mike
kedarrkulkar...
All-Star
35573 Points
5700 Posts
Re: get image from database, resize and display
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
http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspx
u can set fixed height and width of <asp:image ... > control to restrict size of image being displayed on page...
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
mike7510uk
Member
716 Points
334 Posts
Re: get image from database, resize and display
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?
mike7510uk
Member
716 Points
334 Posts
Re: get image from database, resize and display
Jul 06, 2011 07:26 AM|LINK
sorry, that wasnt very clear, here is some code to show how i need this layout...
html etc...
<div id =content>
<table>
<tr><td>img1</td><td>img2</td></tr>
<tr><td>txt1</td><td>txt2</td></tr>
</table>
</div>
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?
kedarrkulkar...
All-Star
35573 Points
5700 Posts
Re: get image from database, resize and display
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" > <HeaderTemplate> <table> <tr> <th> Images </th> </tr> </table> <HeaderTemplate> <ItemTemplate> <table> <tr> <td> <asp:image id="img1" runat="server"> </td> <td> <asp:image id="img2" runat="server"/> </td> </tr> <tr> <td> <asp:label id="lbl1" runat="server"/> </td> <td> <asp:label id="lbl2" runat="server"/> </td> </tr> </table> <ItemTemplate> </asp:Repeater>hope
KK
Please mark as Answer if post helps in resolving your issue
My Site
mike7510uk
Member
716 Points
334 Posts
Re: get image from database, resize and display
Jul 06, 2011 09:07 AM|LINK
yes that seems more like it, but how do i populate it all from DB (images)
mike7510uk
Member
716 Points
334 Posts
Re: get image from database, resize and display
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
etc etc
kedarrkulkar...
All-Star
35573 Points
5700 Posts
Re: get image from database, resize and display
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;
rptList.DataBind();
all records from dataset will be displayed in template format we have set for repeater... for more info about using repeater control read this
http://www.netrostar.com/Tutorials-91-ASP.NET%20Tutorial.%20How%20to%20use%20Repeater
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
mike7510uk
Member
716 Points
334 Posts
Re: get image from database, resize and display
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?
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: get image from database, resize and display
Jul 06, 2011 02:40 PM|LINK
Refer here
http://www.aspsnippets.com/Articles/Display-Images-from-SQL-Server-Database-using-ASP.Net.aspx
More examples
http://www.aspsnippets.com/Search.aspx?q=image%20database
Contact me