一个N小的有关问题,麻烦心目中高手解决
一个N小的问题,麻烦心目中高手解决
ASPX文件
<table style= "width: 725px " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td colspan= "2 " style= "height:15px "> </td>
</tr>
<tr>
<td colspan= "2 " style= "height:35px "> <img src= "images/p_product.gif " width= "725 " height= "35 " /> </td>
</tr>
<tr>
<td colspan= "2 " style= "height:5px "> </td>
</tr>
<tr>
<td style= "height:30px;width:325px; "> 产品名称: <asp:Label id= "ProductName " runat= "server "> </asp:Label> </td>
<td style= "height:30px;width:400px "> 产品编号: <asp:Label id= "ProductType " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td style= "height:30px;width:325px "> 产品类型: <asp:Label id= "ProductClass " runat= "server "> </asp:Label> </td>
<td style= "height:30px;width:400px "> PDF详细资料: </td>
</tr>
<tr>
<td colspan= "2 " style= "height:450px;text-align:center; " valign= "middle "> <asp:Image id= "ProductImg " runat= "server "> </asp:Image> </td>
</tr>
<tr>
<td style= "height:5px "> </td>
<td> </td>
</tr>
</table>
CS文件
private void bindNews(string ProductID)
{
string selSql = "select * from YZProduct where ProductID= " + Request.QueryString[ "ProductID "].ToString();
OleDbConnection conn=new OleDbConnection(connStr);
OleDbCommand selCmd=new OleDbCommand(selSql,conn);
OleDbDataReader sdr;
try
{
conn.Open ();
sdr=selCmd.ExecuteReader ();
while(sdr.Read ())
{
this.ProductType .Text =sdr[ "ProductType "].ToString ();
this.ProductName .Text =sdr[ "ProductName "].ToString ();
this.ProductClass .Text =sdr[ "ProductClass "].ToString ();
this.ProductImg.ImageUrl =sdr[ "ProductImg "].ToString ();
}
}
catch(System.Exception ex)
{
throw new Exception (ex.Message );
}
finally
{
conn.Close ();
}
}
数据库表格
productPDF 里面数据是:http://www.hpwangaga/pdf/120.pdf
请问怎么在 PDF详细资料:实现下载功能
------解决方案--------------------
while(sdr.Read ())
{
this.ProductType .Text =sdr[ "ProductType "].ToString ();
this.ProductName .Text =sdr[ "ProductName "].ToString ();
this.ProductClass .Text =sdr[ "ProductClass "].ToString ();
this.ProductImg.ImageUrl =sdr[ "ProductImg "].ToString ();
}
总共就4个Label,用while干吗呢?if(sdr.Read())就可以了
如果productPDF里存的是地址 "http://www.hpwangaga/pdf/120.pdf ",那你不应该用Image控件,而应该使用HyperLink控件,其中的ImageUrl可以指定图片路径,而NavigateUrl可以设为 "http://www.hpwangaga/pdf/120.pdf "这个下载地址
ASPX文件
<table style= "width: 725px " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td colspan= "2 " style= "height:15px "> </td>
</tr>
<tr>
<td colspan= "2 " style= "height:35px "> <img src= "images/p_product.gif " width= "725 " height= "35 " /> </td>
</tr>
<tr>
<td colspan= "2 " style= "height:5px "> </td>
</tr>
<tr>
<td style= "height:30px;width:325px; "> 产品名称: <asp:Label id= "ProductName " runat= "server "> </asp:Label> </td>
<td style= "height:30px;width:400px "> 产品编号: <asp:Label id= "ProductType " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td style= "height:30px;width:325px "> 产品类型: <asp:Label id= "ProductClass " runat= "server "> </asp:Label> </td>
<td style= "height:30px;width:400px "> PDF详细资料: </td>
</tr>
<tr>
<td colspan= "2 " style= "height:450px;text-align:center; " valign= "middle "> <asp:Image id= "ProductImg " runat= "server "> </asp:Image> </td>
</tr>
<tr>
<td style= "height:5px "> </td>
<td> </td>
</tr>
</table>
CS文件
private void bindNews(string ProductID)
{
string selSql = "select * from YZProduct where ProductID= " + Request.QueryString[ "ProductID "].ToString();
OleDbConnection conn=new OleDbConnection(connStr);
OleDbCommand selCmd=new OleDbCommand(selSql,conn);
OleDbDataReader sdr;
try
{
conn.Open ();
sdr=selCmd.ExecuteReader ();
while(sdr.Read ())
{
this.ProductType .Text =sdr[ "ProductType "].ToString ();
this.ProductName .Text =sdr[ "ProductName "].ToString ();
this.ProductClass .Text =sdr[ "ProductClass "].ToString ();
this.ProductImg.ImageUrl =sdr[ "ProductImg "].ToString ();
}
}
catch(System.Exception ex)
{
throw new Exception (ex.Message );
}
finally
{
conn.Close ();
}
}
数据库表格
productPDF 里面数据是:http://www.hpwangaga/pdf/120.pdf
请问怎么在 PDF详细资料:实现下载功能
------解决方案--------------------
while(sdr.Read ())
{
this.ProductType .Text =sdr[ "ProductType "].ToString ();
this.ProductName .Text =sdr[ "ProductName "].ToString ();
this.ProductClass .Text =sdr[ "ProductClass "].ToString ();
this.ProductImg.ImageUrl =sdr[ "ProductImg "].ToString ();
}
总共就4个Label,用while干吗呢?if(sdr.Read())就可以了
如果productPDF里存的是地址 "http://www.hpwangaga/pdf/120.pdf ",那你不应该用Image控件,而应该使用HyperLink控件,其中的ImageUrl可以指定图片路径,而NavigateUrl可以设为 "http://www.hpwangaga/pdf/120.pdf "这个下载地址