Using DataList
-
How can i develop a product catalog that diplay a large picture of product and put the description with price under the picture? I use DataList, but the pictures don't appear. Is it true, if i use image handler, my data type for image must be in binary? My current data type for image now is varchar. <asp:DataList id="dlstImages" RepeatColumns="3" runat="server"> <ItemTemplate> <asp:Image ID="Image1" ImageUrl='<%# Eval("Name", "~/UploadImages/{0}") %>' style="width:200px" Runat="server" /> <br /> <%# Eval("Name") %> </ItemTemplate> </asp:DataList>
-
How can i develop a product catalog that diplay a large picture of product and put the description with price under the picture? I use DataList, but the pictures don't appear. Is it true, if i use image handler, my data type for image must be in binary? My current data type for image now is varchar. <asp:DataList id="dlstImages" RepeatColumns="3" runat="server"> <ItemTemplate> <asp:Image ID="Image1" ImageUrl='<%# Eval("Name", "~/UploadImages/{0}") %>' style="width:200px" Runat="server" /> <br /> <%# Eval("Name") %> </ItemTemplate> </asp:DataList>
Varchar will screw up the data, I would guess. You should definitely use binary fields. However, what you are doing here appears to be linking to an image on the server, not the image in the database; this means that the image name would be in varchar. Is your intention to refer to a folder, or to display the image data directly? Also, you might want to use tags instead of controls; most people would consider it better practice to use the simplest control possible unless there's a good reason not to.
-
Varchar will screw up the data, I would guess. You should definitely use binary fields. However, what you are doing here appears to be linking to an image on the server, not the image in the database; this means that the image name would be in varchar. Is your intention to refer to a folder, or to display the image data directly? Also, you might want to use tags instead of controls; most people would consider it better practice to use the simplest control possible unless there's a good reason not to.
I use datatype varchar for image (put image path) and display in gridview, this is fine. But when i use the same datatype and display in datalist, the image didn't appear, but the description and price for the product appear. If i use binary for image, then i need to upload the picture to DB, rite? and also use generic handler. what is the easier way to display image for product and the details from different product categories (it's like e-commerce application)?
-
I use datatype varchar for image (put image path) and display in gridview, this is fine. But when i use the same datatype and display in datalist, the image didn't appear, but the description and price for the product appear. If i use binary for image, then i need to upload the picture to DB, rite? and also use generic handler. what is the easier way to display image for product and the details from different product categories (it's like e-commerce application)?
Displaying binary data directly in ASP is a bit hairy. I'd stick with an <img tag; View Source in IE to see what the path is, and check the data list to see if it's formatting your HTML as text - there should be a property in there somewhere. Again, View Source will help you out. My instinct is that it's some kind of HTML formatting issue.