| | |
Not able to display all image from DB except 1st image.
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jan 2009
Posts: 1
Reputation:
Solved Threads: 0
On the selection of value from dropdownlist, image is displayed in display page. Selectedvalue has many image in DB say 50+ but as per my query below it reads only 1st image of DB i.e.1st image of database. So do let me know where my code is gng wrong.
CODE VIEW OF DISPLAY PAGE:
SOURCE VIEW OF DISPLAY PAGE:
CODE VIEW OF READ PAGE:
CODE VIEW OF DISPLAY PAGE:
asp.net Syntax (Toggle Plain Text)
public string FormatURL(object strArgument) { return ("Read.aspx?Coins=" + strArgument); }
SOURCE VIEW OF DISPLAY PAGE:
asp.net Syntax (Toggle Plain Text)
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> Image:<asp:Image ID="Image1" runat="server" Height="50px" Width="100px" imageUrl='<%#FormatURL(DataBinder.Eval(Container.DataItem, "coins")) %>'/> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CoinsString %>" SelectCommand="SELECT [imgdata], [imgtype], [Coins] FROM [TABLE] WHERE ([Coins] = @Coins)"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="Coins" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
CODE VIEW OF READ PAGE:
asp.net Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { string strImageID = Request.QueryString[0]; SqlConnection cn = new SqlConnection("Data Source=MAKJAIN;Initial Catalog=DATABASE;Integrated Security=True"); SqlCommand cmd = new SqlCommand("select imgtype,imgdata from TABLE where coins='" + strImageID + "' ", cn); // try { cn.Open(); SqlDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) //yup we found our image { //retrving the image content type Response.ContentType = dr["imgtype"].ToString(); //displaying the image Response.BinaryWrite((byte[])dr["imgdata"]); } cn.Close(); } catch { }
Last edited by peter_budo; Jan 11th, 2009 at 2:38 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- converting binary data into image in asp.net(vb code) (ASP.NET)
- EOF problem (C++)
- Need help to display data with image into page (ASP.NET)
- how to display one image per day from an array? (JSP)
- This page cannot be displayed - only in Google (Windows 95 / 98 / Me)
- Selectively Printing only Certain Divs (javascript/css question) (JavaScript / DHTML / AJAX)
- Toshiba satellite LCD showing black bands (Monitors, Displays and Video Cards)
- CSS scrollbar ??? (JavaScript / DHTML / AJAX)
- Radio/TV/Print & Web Advertsing to 2 million weekly just $24.99/Month! (Ad Space for Sale)
Other Threads in the ASP.NET Forum
- Previous Thread: a creative question
- Next Thread: How to display all ASP.Net ProfileProvider User Profiles ??
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





