这是一个基于Web的应用程序,我用来将图像存储在数据库中,并在数据库中存储url. [英] It is a web based application and I use to store the images in a database storing urls in a database
问题描述
我使用HTTP处理程序ShowImage.aspx通过Product,aspx检索图像,所有图像都显示出来.但是问题是,当我单击图像按钮以查看特定产品的产品详细信息时,将显示所有产品的详细信息.我需要单击图像"按钮单击的该产品的详细信息.我粘贴在此处的编码页面
请告诉我
真诚的
Upendra
数据库字段
p_id int未经检查(身份)
p_name varchar(50)已检查(存储图像的网址)
品牌varchar(50)已检查(产品的品牌名称)
p_file图像已检查(存储图像)
价格int已检查(产品价格)
说明文字已选中(产品说明)
Product.aspx
I retrieve the images by the Product,aspx using a HTTP handler ShowImage.aspx all the images are displayed . But the problem is that when I click on the image button for looking the product details of a particular product then the details of all the products are displayed . I need the details of that product which has been clicked by the Image button The pages of coding I am pasting here
Show me the way please
Sincerely Yours
Upendra
Database fields
p_id int Unchecked (Identity)
p_name varchar(50) Checked (storing the urls of images)
brand varchar(50) Checked (brand name of the product)
p_file image Checked (storing the image)
price int Checked (price of the product)
description text Checked (Descriptin of the product)
Product.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Product.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [p_id],[p_name], [brand], [p_file], [price] FROM [mobile]">
</asp:SqlDataSource>
<br />
<br />
<asp:DataList ID="DataList1" runat="server" DataKeyField="p_id"
DataSourceID="SqlDataSource1" RepeatColumns="4"
RepeatDirection="Horizontal">
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl='<%#"ShowImage.ashx?p_id="+ Eval("p_id")%>' Height="150px" Width="150px" PostBackUrl='<%# String.Format("~/ProductDetails.aspx?p_id={0}", Eval("p_id"))%>' ></asp:ImageButton>
/ItemTemplate>
</asp:DataList>
</div>
</form>
</body> </html>
推荐答案
ConnectionStrings:ConnectionString %> " span> =" 从[手机]中选择[p_id],[p_name],[品牌],[p_file],[price]" < /asp:SqlDataSource > < br > < br > < asp:DataList ID =" runat 服务器" DataKeyField p_id" span> =" SqlDataSource1" RepeatColumns =" span> =" 水平" > < ItemTemplate > < asp:ImageButton ID =" runat 服务器" ImageUrl <%#" + Eval(" )%> ' 高度 =" 150像素" 宽度 =" PostBackUrl =' <%#字符串 .Format( 〜/ProductDetails.aspx?p_id = {0}",Eval( p_id"))) < > /ItemTemplate> < /asp:DataList > < /div > < /form > < /body > < /html >
ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [p_id],[p_name], [brand], [p_file], [price] FROM [mobile]"> </asp:SqlDataSource> <br /> <br /> <asp:DataList ID="DataList1" runat="server" DataKeyField="p_id" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatDirection="Horizontal"> <ItemTemplate> <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl='<%#"ShowImage.ashx?p_id="+ Eval("p_id")%>' Height="150px" Width="150px" PostBackUrl='<%# String.Format("~/ProductDetails.aspx?p_id={0}", Eval("p_id"))%>' ></asp:ImageButton> /ItemTemplate> </asp:DataList> </div> </form> </body> </html>
在showimages.aspx的pageload事件中
编写以下代码
Hi,
in pageload event of showimages.aspx
write following code
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
string p_id= Request.QueryString["p_id"].ToString();
// after getting pat id write code to retrive product information
}
}
catch (Exception Ex)
{
}
}
祝你好运
best luck
这篇关于这是一个基于Web的应用程序,我用来将图像存储在数据库中,并在数据库中存储url.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!