我做个在线咨询和点评的界面。
布局是在线咨询和点评在同一个界面,一个咨询对应多个点评,咨询有上下页的按钮,
点评也有上下页的按钮,现在出现问题了,就是不好让它们对应的显示。
怎么个思路呀???实现的功能是:点击咨询的翻页,对应的点评更新,点击点评时,对应的咨询部翻页。可是我现在点击点评时,咨询也翻页!!!
我分别写了二个上下页 public partial class TestOK : System.Web.UI.Page
{
private SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
Hashtable ht = new Hashtable();
public int num = 1;
public int PageNum = 0;
public bool F = true;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string str = "";
if (F)
{
string strTxt = "select * from online order by id";
repText.DataSource = pdsTxt(strTxt);
repText.DataBind();
}
foreach (int Ok in ht.Keys)
{
if (PageNum == Ok)
{
str = "select * from dp where dp.id= " + ht[Ok] + "";
}
}
repans.DataSource = pds(str);
repans.DataBind();
} } public PagedDataSource pdsTxt(string strTxt)
{
SqlCommand com = new SqlCommand(strTxt, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
conn.Open();
adapter.Fill(ds);
PagedDataSource pds = new PagedDataSource();
com.Dispose();
conn.Close();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
int Pageindex;
if (Request.QueryString["page"] != null)
{
Pageindex = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
Pageindex = 1;
}
//设置当前页
if (Pageindex < 1)
{
Pageindex = 1;
}
pds.CurrentPageIndex = Pageindex - 1;
repText.DataSource = pds;
repText.DataBind();
//显示上下翻页
lbn_Prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex - 1);
lbn_Next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex + 1);
//确定链接的显示方式
if (Pageindex <= 1 && pds.PageCount <= 1)
{
lbn_Prev.NavigateUrl = "";
lbn_Next.NavigateUrl = "";
}
if (Pageindex <= 1 && pds.PageCount > 1)
{
lbn_Prev.NavigateUrl = "";
}
if (Pageindex >= pds.PageCount)
{
lbn_Next.NavigateUrl = "";
}
foreach (DataRow row in ds.Tables[0].Rows)
{
ht.Add(num++, row["ID"]);
}
PageNum = Pageindex;
return pds;
} public PagedDataSource pds(string str)
{
SqlCommand com = new SqlCommand(str, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
conn.Open();
adapter.Fill(ds);
PagedDataSource pds = new PagedDataSource();
com.Dispose();
conn.Close();
//设置数据源(DataTable类型)
pds.DataSource = ds.Tables[0].DefaultView;
//允许分页
pds.AllowPaging = true;
//每页显示的行数
pds.PageSize = 1;
repans.DataSource = pds;
repans.DataBind();
int Pageindex;
//当前页面从Page查询参数获取
if (Request.QueryString["page"] != null)
{
Pageindex = Convert.ToInt32(Request.QueryString["pageT"]);
}
else
{
Pageindex = 1;
}
//设置当前页
if (Pageindex < 1)
{
Pageindex = 1;
}
pds.CurrentPageIndex = Pageindex - 1;
//显示上下翻页
lbn_APre.NavigateUrl = Request.CurrentExecutionFilePath + "?pageT=" + (Pageindex - 1);
lbn_ANext.NavigateUrl = Request.CurrentExecutionFilePath + "??pageT=" + (Pageindex + 1);
//确定链接的显示方式
if (Pageindex <= 1 && pds.PageCount <= 1)
{
lbn_APre.NavigateUrl = "";
lbn_ANext.NavigateUrl = "";
}
if (Pageindex <= 1 && pds.PageCount > 1)
{
lbn_APre.NavigateUrl = "";
}
if (Pageindex >= pds.PageCount)
{
lbn_ANext.NavigateUrl = "";
}
return pds;
} protected void ImgbtnOK_Click(object sender, ImageClickEventArgs e)
{
//pdsSql(Convert.ToInt32(txtbox1.Text.Trim()), strSql);
}
}
布局是在线咨询和点评在同一个界面,一个咨询对应多个点评,咨询有上下页的按钮,
点评也有上下页的按钮,现在出现问题了,就是不好让它们对应的显示。
怎么个思路呀???实现的功能是:点击咨询的翻页,对应的点评更新,点击点评时,对应的咨询部翻页。可是我现在点击点评时,咨询也翻页!!!
我分别写了二个上下页 public partial class TestOK : System.Web.UI.Page
{
private SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
Hashtable ht = new Hashtable();
public int num = 1;
public int PageNum = 0;
public bool F = true;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string str = "";
if (F)
{
string strTxt = "select * from online order by id";
repText.DataSource = pdsTxt(strTxt);
repText.DataBind();
}
foreach (int Ok in ht.Keys)
{
if (PageNum == Ok)
{
str = "select * from dp where dp.id= " + ht[Ok] + "";
}
}
repans.DataSource = pds(str);
repans.DataBind();
} } public PagedDataSource pdsTxt(string strTxt)
{
SqlCommand com = new SqlCommand(strTxt, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
conn.Open();
adapter.Fill(ds);
PagedDataSource pds = new PagedDataSource();
com.Dispose();
conn.Close();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
int Pageindex;
if (Request.QueryString["page"] != null)
{
Pageindex = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
Pageindex = 1;
}
//设置当前页
if (Pageindex < 1)
{
Pageindex = 1;
}
pds.CurrentPageIndex = Pageindex - 1;
repText.DataSource = pds;
repText.DataBind();
//显示上下翻页
lbn_Prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex - 1);
lbn_Next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex + 1);
//确定链接的显示方式
if (Pageindex <= 1 && pds.PageCount <= 1)
{
lbn_Prev.NavigateUrl = "";
lbn_Next.NavigateUrl = "";
}
if (Pageindex <= 1 && pds.PageCount > 1)
{
lbn_Prev.NavigateUrl = "";
}
if (Pageindex >= pds.PageCount)
{
lbn_Next.NavigateUrl = "";
}
foreach (DataRow row in ds.Tables[0].Rows)
{
ht.Add(num++, row["ID"]);
}
PageNum = Pageindex;
return pds;
} public PagedDataSource pds(string str)
{
SqlCommand com = new SqlCommand(str, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
conn.Open();
adapter.Fill(ds);
PagedDataSource pds = new PagedDataSource();
com.Dispose();
conn.Close();
//设置数据源(DataTable类型)
pds.DataSource = ds.Tables[0].DefaultView;
//允许分页
pds.AllowPaging = true;
//每页显示的行数
pds.PageSize = 1;
repans.DataSource = pds;
repans.DataBind();
int Pageindex;
//当前页面从Page查询参数获取
if (Request.QueryString["page"] != null)
{
Pageindex = Convert.ToInt32(Request.QueryString["pageT"]);
}
else
{
Pageindex = 1;
}
//设置当前页
if (Pageindex < 1)
{
Pageindex = 1;
}
pds.CurrentPageIndex = Pageindex - 1;
//显示上下翻页
lbn_APre.NavigateUrl = Request.CurrentExecutionFilePath + "?pageT=" + (Pageindex - 1);
lbn_ANext.NavigateUrl = Request.CurrentExecutionFilePath + "??pageT=" + (Pageindex + 1);
//确定链接的显示方式
if (Pageindex <= 1 && pds.PageCount <= 1)
{
lbn_APre.NavigateUrl = "";
lbn_ANext.NavigateUrl = "";
}
if (Pageindex <= 1 && pds.PageCount > 1)
{
lbn_APre.NavigateUrl = "";
}
if (Pageindex >= pds.PageCount)
{
lbn_ANext.NavigateUrl = "";
}
return pds;
} protected void ImgbtnOK_Click(object sender, ImageClickEventArgs e)
{
//pdsSql(Convert.ToInt32(txtbox1.Text.Trim()), strSql);
}
}
解决方案 »
- 在复合控件中,如何对TextBox的TextChanged事件进行冒泡处理
- ASP.NET + Sql Server图片存储
- Waiting for you...
- 如何使背景边框随页面长度的变化而变化?
- 请问我down的DotNetNuke在本机上运行不了,怎么弄?
- 论坛开发问题,有分送啊。还想多送,系统说不行啊。
- 请教一个web services的问题
- 请问fckeditor在客户端IE上不能正常使用的问题?
- 求:ASP.NET中如何实现富文本编辑功能?
- 请求帮助!在线等待!
- 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错
- 我的分页控件最后面的类型选择怎么没有反应啊?新手上路
public int PageNum = 0;
这是想保存咨询的ID,以便点评对应显示
我咨询的ID是点评的外键,
现在的问题是不好获取当前页的咨询ID,
protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("Repeater2") as Repeater;
DataRowView rowv = (DataRowView)e.Item.DataItem;
}
} http://topic.csdn.net/u/20090911/14/5267b5fc-0ac7-43e0-840a-639b38610479.html
private SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
ParentRepeater.ItemDataBound += new RepeaterItemEventHandler(ParentRepeater_ItemDataBound);
if (!IsPostBack)
{
string strTxt = "select * from online order by id";
SqlCommand com = new SqlCommand(strTxt, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
conn.Open();
adapter.Fill(ds);
PagedDataSource pds = new PagedDataSource();
conn.Close();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 1;
int Pageindex;
if (Request.QueryString["page"] != null)
{
Pageindex = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
Pageindex = 1;
}
//设置当前页
if (Pageindex < 1)
{
Pageindex = 1;
}
pds.CurrentPageIndex = Pageindex - 1;
ParentRepeater.DataSource = pds;
ParentRepeater.DataBind();
//显示上下翻页
lbn_Prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex - 1);
lbn_Next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex + 1);
//确定链接的显示方式
if (Pageindex <= 1 && pds.PageCount <= 1)
{
lbn_Prev.NavigateUrl = "";
lbn_Next.NavigateUrl = "";
}
if (Pageindex <= 1 && pds.PageCount > 1)
{
lbn_Prev.NavigateUrl = "";
}
if (Pageindex >= pds.PageCount)
{
lbn_Next.NavigateUrl = "";
}
}
} void ParentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = (DataRowView)e.Item.DataItem;
string parentID = row["ID"].ToString();
string strSql = "select * from dp where id=" + parentID + " order by C_ID";
SqlCommand com = new SqlCommand(strSql, conn);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet();
adapter.Fill(ds);
ChildRepeater.DataSource = ds.Tables[0].DefaultView;
ChildRepeater.DataBind();
}
}
现在能实现的只是:点击咨询上下页,下面的点评能对应都显示出来,可是我想把点评也分页显示出来,也有使用上下页的功能,可是当我加进去时,就出问题了就是使用点评上下页功能时,咨询就跳到第一页显示,我想实现点击点评上下页时,咨询不变化
Page=XXX&PageT=XXX
lbn_Prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex - 1);
lbn_Next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (Pageindex + 1);
你用链接来实现翻页相当于跳转到新页面,不在原来页面上了,一定会重新载入咨询部分的啊,像这样就要像16喽说的传两个参数,一个是咨询的当前页,一个是评价的当前页。
lbn_APre.NavigateUrl = Request.CurrentExecutionFilePath + "?pageT=" + (Pageindex - 1);
lbn_ANext.NavigateUrl = Request.CurrentExecutionFilePath + "??pageT=" + (Pageindex + 1);咨询部分的翻页可以只传一个参数,评价部分的翻页就要同时传两个参数。
咨询列
点评列
楼主最好是
选择一条咨询列或点评列,查询一次相关的记录绑定repeater
然后主要的还是用户可以点击一个"全部的点评" link进行恢复加载全部数据。