图片分页显示问题?
例下:
显示当前图片 显示上一页图片 显示下一页图片
一个页面中显示三个图片,也就是数据表中的三个记录。我怎么显示当前记录(图片),也是上一记录(图片),和下一记录(图片),点上一记录图片
就会以当前图片显示出来。上一记录(图片)自动显示当前图片的上一条记录》》》》》》
------解决方案--------------------
这个和文章的上一篇和下一篇类似:
转:
public string strTitle;
public string strAuthor;
public string strContent;
public string strNext;
public string strId;
public string strPreId;
public string strPreTitle;
public int intMin;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
BindData();
Pre();
next();
min();
}
}
public void BindData()
{
SqlConnection sqlCon=DBCon.sqlCon1();
SqlCommand sqlCmd=new SqlCommand("select * from news where new_type=1 and new_id='"+Request["id"]+"'",sqlCon);
sqlCon.Open();
SqlDataReader dr=sqlCmd.ExecuteReader();
if(dr.Read())
{
strTitle=dr["New_Title"].ToString();
strAuthor=dr["New_Author"].ToString();
strContent=dr["New_Content"].ToString();
if(Convert.ToInt32(strPreId)==intMin)
{
Response.Write("djfkejfie");
}
}
sqlCon.Close();
}
public void min()
{
SqlConnection sqlCon=DBCon.sqlCon1();
sqlCon.Open();
SqlCommand sqlCmd=new SqlCommand("select min(New_Id) aa from news where new_type=1",sqlCon);
SqlDataReader dr=sqlCmd.ExecuteReader();
if(dr.Read())
{
intMin=Convert.ToInt32(dr["aa"]);
Response.Write(intMin.ToString());
}
sqlCmd.Dispose();
sqlCon.Close();
}
public void next()
{
SqlConnection sqlCon=DBCon.sqlCon1();
sqlCon.Open();
SqlCommand sqlCmd1=new SqlCommand("select top 1 new_title,new_id from news where new_type=1 and new_id>'"+Request["id"]+"'",sqlCon);
SqlDataReader dr1=sqlCmd1.ExecuteReader();
if(dr1.Read())
{
strNext=dr1["new_title"].ToString();
strId=dr1["new_id"].ToString();
}
sqlCmd1.Dispose();
sqlCon.Close();
}
public void Pre()
{
SqlConnection sqlCon=DBCon.sqlCon1();
sqlCon.Open();
SqlCommand sqlCmdPre=new SqlCommand("select top 1 new_title,new_id from news where new_id <'"+Request["id"]+"' order by new_Id desc",sqlCon);
SqlDataReader drPre=sqlCmdPre.ExecuteReader();
while(drPre.Read())
{
strPreId=drPre["new_id"].ToString();
strPreTitle=drPre["new_title"].ToString();
if(strPreTitle=="")
{
strPreTitle="没有记录";
}
else
strPreTitle=strPreTitle;
}
sqlCmdPre.Dispose();
sqlCon.Close();
}
前台代码
下一篇: <a herf=show_new.aspx?id= <%=strId%>> <%strNext%> </a>
上一篇:: <a herf=show_new.aspx?id= <%=strPreId>> <%strPreTitle%> </a>