protected void list_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{ //显示记录数
Label lblCurrentPage = (Label)(e.Row.FindControl("lblCurrentPage"));
Label lblTotalPage = (Label)(e.Row.FindControl("lblTotalPage"));
Label lblTotalCount = (Label)(e.Row.FindControl("lblTotalCount"));
lblCurrentPage.Text = this.currentPage.ToString();
lblTotalPage.Text = this.totalPage.ToString();
lblTotalCount.Text = this.totalCount.ToString();
//绑定分页按钮
HyperLink linkFirst = (HyperLink)(e.Row.FindControl("linkFirst"));
HyperLink linkPrev = (HyperLink)(e.Row.FindControl("linkPrev"));
HyperLink linkNext = (HyperLink)(e.Row.FindControl("linkNext"));
HyperLink linkLast = (HyperLink)(e.Row.FindControl("linkLast"));
if (currentPage > 1)
{
hlFirst.NavigateUrl = "?id=1";
hlPrevious.NavigateUrl = "?id=" + (this.currentPage - 1);
}
if (currentPage < totalPage)
{
hlNext.NavigateUrl = "?id=" + (this.currentPage + 1);
hlLast.NavigateUrl = "?id=" + this.totalPage;
}
//绑定转到第几页
DropDownList ddlRandom = (DropDownList)(e.Row.FindControl("ddlRandom"));
for (int i = 1; i <= totalPage; i++)
{
ddlRandom.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
ddlRandom.SelectedIndex = currentPage - 1;
}
if (e.Row.RowState == DataControlRowState.Normal)
{
}
}
protected void gvFavorite_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string tempeteId = this.gvFavorite.DataKeys[e.RowIndex].Value.ToString();
Favorites favorites = new Favorites();
bool flag = favorites.DeleteFavorite(tempeteId);
if (flag)
{
Response.Write("<script lauguage='javascript'> alert('你已经成功删除了一条模板')</script>");
} else
{
Response.Write("<script lauguage='javascript'> alert('删除失败')</script>");
}
this.BindGvFavorite(); }
protected void ddlRandom_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow gvr = this.list.BottomPagerRow;
DropDownList ddlRandom = (DropDownList)(gvr.FindControl("ddlRandom"));
this.currentPage = Convert.ToInt32(ddlRandom.SelectedIndex.ToString()) + 1;
Response.Redirect("?id=" + this.currentPage); }错误如下:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0117: “Admin_News”并不包含“currentPage”的定义源错误: 行 21: Label lblTotalPage = (Label)(e.Row.FindControl("lblTotalPage"));
行 22: Label lblTotalCount = (Label)(e.Row.FindControl("lblTotalCount"));
行 23: lblCurrentPage.Text = this.currentPage.ToString();
行 24: lblTotalPage.Text = this.totalPage.ToString();
行 25: lblTotalCount.Text = this.totalCount.ToString();
{
if (e.Row.RowType == DataControlRowType.Pager)
{ //显示记录数
Label lblCurrentPage = (Label)(e.Row.FindControl("lblCurrentPage"));
Label lblTotalPage = (Label)(e.Row.FindControl("lblTotalPage"));
Label lblTotalCount = (Label)(e.Row.FindControl("lblTotalCount"));
lblCurrentPage.Text = this.currentPage.ToString();
lblTotalPage.Text = this.totalPage.ToString();
lblTotalCount.Text = this.totalCount.ToString();
//绑定分页按钮
HyperLink linkFirst = (HyperLink)(e.Row.FindControl("linkFirst"));
HyperLink linkPrev = (HyperLink)(e.Row.FindControl("linkPrev"));
HyperLink linkNext = (HyperLink)(e.Row.FindControl("linkNext"));
HyperLink linkLast = (HyperLink)(e.Row.FindControl("linkLast"));
if (currentPage > 1)
{
hlFirst.NavigateUrl = "?id=1";
hlPrevious.NavigateUrl = "?id=" + (this.currentPage - 1);
}
if (currentPage < totalPage)
{
hlNext.NavigateUrl = "?id=" + (this.currentPage + 1);
hlLast.NavigateUrl = "?id=" + this.totalPage;
}
//绑定转到第几页
DropDownList ddlRandom = (DropDownList)(e.Row.FindControl("ddlRandom"));
for (int i = 1; i <= totalPage; i++)
{
ddlRandom.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
ddlRandom.SelectedIndex = currentPage - 1;
}
if (e.Row.RowState == DataControlRowState.Normal)
{
}
}
protected void gvFavorite_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string tempeteId = this.gvFavorite.DataKeys[e.RowIndex].Value.ToString();
Favorites favorites = new Favorites();
bool flag = favorites.DeleteFavorite(tempeteId);
if (flag)
{
Response.Write("<script lauguage='javascript'> alert('你已经成功删除了一条模板')</script>");
} else
{
Response.Write("<script lauguage='javascript'> alert('删除失败')</script>");
}
this.BindGvFavorite(); }
protected void ddlRandom_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow gvr = this.list.BottomPagerRow;
DropDownList ddlRandom = (DropDownList)(gvr.FindControl("ddlRandom"));
this.currentPage = Convert.ToInt32(ddlRandom.SelectedIndex.ToString()) + 1;
Response.Redirect("?id=" + this.currentPage); }错误如下:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0117: “Admin_News”并不包含“currentPage”的定义源错误: 行 21: Label lblTotalPage = (Label)(e.Row.FindControl("lblTotalPage"));
行 22: Label lblTotalCount = (Label)(e.Row.FindControl("lblTotalCount"));
行 23: lblCurrentPage.Text = this.currentPage.ToString();
行 24: lblTotalPage.Text = this.totalPage.ToString();
行 25: lblTotalCount.Text = this.totalCount.ToString();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货