<!-- 第一个form-->
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
<form id="form1" name="form1" method="post" action="">
ItemTemplate>
<table id="table1" border="1" style="font-size:12pt; width:500px; height:auto ; margin-left:100px; margin-top: 10px;" cellpadding="0" cellspacing="0" runat="server" >
<tr>
<td>
<label>软件名称</label>
</td>
<td colspan="3">
<asp:Label ID="Label10" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Name")%>></asp:Label>
</td>
</tr>
<tr>
<td >
<label >软件大小</label>
</td>
<td>
<asp:Label ID="Label12" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Dimension")%>></asp:Label>
</td>
<td>
<label >软件类别</label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Class")%>></asp:Label>
</td>
</tr>
<tr>
<td >
<label >软件语言</label>
</td>
<td>
<asp:Label ID="Label3" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Language")%>></asp:Label>
</td>
<td>
<label >下载次数</label>
</td>
<td>
<asp:Label ID="Label4" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Dlcount")%>></asp:Label>
</td>
</tr>
<tr>
<td >
<label >插件情况</label>
</td>
<td>
<asp:Label ID="Label5" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Plug_ins")%>></asp:Label>
</td>
<td >
<label >软件授权</label>
</td>
<td>
<asp:Label ID="Label6" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Authorized")%>></asp:Label>
</td>
</tr>
<tr>
<td >
<label >更新时间</label>
</td>
<td>
<asp:Label ID="Label7" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Updatetime")%>></asp:Label>
</td>
<td >
<label >应用平台</label>
</td>
<td>
<asp:Label ID="Label8" runat="server" Text=<%# DataBinder.Eval(Container.DataItem,"Platform")%>></asp:Label>
</td>
</tr>
<tr>
<td colspan="4" align="right">
<a href="<%# DataBinder.Eval(Container.DataItem,"Path")%>" style="color:Red; text-decoration :none" target="_blank ">点击下载</a>
</td>
</tr>
</table>
</ItemTemplate>
<!-- Content
-->
</form>
</asp:Panel>
<!-- 第二个form-->
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
<form id="form2" name="form2" method="post" action="">
<!-- Content
-->
</form>
</asp:Panel>
<!--下面的只是针对第一个form的数据库连接代码-->
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class download : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//SqlConnection sqlcon = new SqlConnection("server=192.168.24.108;database=office;uid=sa;pwd=weie123");
//sqlcon.Open();
//Response.Write(sqlcon.State.ToString());
string newsid;
if (Request.QueryString.HasKeys())
{
//获取新闻纪录的ID号
newsid = Request.QueryString["id"].ToString().Trim();
//连接字符串
SqlConnection sqlcon = new SqlConnection("server=192.168.24.108;database=office;uid=sa;pwd=weie123");
sqlcon.Open();
//查找newsid对应的新闻纪录的SQL语句
string sqltopadcom = "select * from tb_SoftManager where ID='" + newsid + "'";
//更新点击率字段的SQL语句
string sqlupdatacom = "Update tb_SoftManager set Dlcount=Dlcount+1 where ID='" + newsid + "'";
//更新点击率字段值
SqlCommand cmd = new SqlCommand(sqlupdatacom, sqlcon);
cmd.ExecuteNonQuery();
//绑定纪录
SqlDataAdapter myda = new SqlDataAdapter(sqltopadcom, sqlcon);
DataSet myds = new DataSet();
myda.Fill(myds, "lihu");
//绑定纪录到视图
DataList1.DataSource = myds.Tables["lihu"];
DataList1.DataBind();
sqlcon.Close();
}
else
{
Response.Redirect("download.aspx");//若直接输入url访问,因无ID,所以返回新闻主页面
}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
000问题是刚开始我没有用panel,只有第一个form时能连接到数据库,也能很好的显示并且能FTP下载。现在我多加了一个表(当然也可以是多个表),并且用panel来分别包装两个表达到分别选定ID来查询数据库时出错了,现在不晓得该怎么写连接的代码,希望高手们能给个详细的解答!小弟 感激不尽!!