如何在Page_Load()里获取DataList里的控件值?
首先声明我不是要做分页。前一个页面跳转时代有一个参数,根据参数查询显示在DataList,取DataList里XX控件的值作为当前面的标题(Title)还有个Label也...
首先声明我不是要做分页。
前一个页面跳转时代有一个参数,根据参数查询显示在DataList,取DataList里XX控件的值作为当前面的标题(Title)还有个Label也要用。。。。 展开
前一个页面跳转时代有一个参数,根据参数查询显示在DataList,取DataList里XX控件的值作为当前面的标题(Title)还有个Label也要用。。。。 展开
6个回答
展开全部
哪句不懂在线问我
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
using (SqlConnection conn = new SqlConnection
(System.Configuration.ConfigurationManager
.ConnectionStrings["NorthwindConn"].ConnectionString))
{
conn.Open();
SqlDataAdapter sqladp = new SqlDataAdapter
("SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products]", conn);
DataTable dt = new DataTable();
sqladp.Fill(dt);
PagedDataSource SQLpaged = new PagedDataSource();
SQLpaged.DataSource = dt.DefaultView;
SQLpaged.AllowPaging = true;
SQLpaged.PageSize = 20;
int this_Page;
if (Request.QueryString["Page"] != null)
this_Page = Convert.ToInt32(Request.QueryString["Page"]);
else
this_Page = 1;
SQLpaged.CurrentPageIndex = this_Page - 1;
Label1.Text = "当前页:" + this_Page.ToString() + "/" + SQLpaged.PageCount;
if (!SQLpaged.IsFirstPage)
HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(this_Page - 1);
if (!SQLpaged.IsLastPage)
HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(this_Page + 1);
DataList1.DataSource = SQLpaged;
DataList1.DataBind();
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
using (SqlConnection conn = new SqlConnection
(System.Configuration.ConfigurationManager
.ConnectionStrings["NorthwindConn"].ConnectionString))
{
conn.Open();
SqlDataAdapter sqladp = new SqlDataAdapter
("SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products]", conn);
DataTable dt = new DataTable();
sqladp.Fill(dt);
PagedDataSource SQLpaged = new PagedDataSource();
SQLpaged.DataSource = dt.DefaultView;
SQLpaged.AllowPaging = true;
SQLpaged.PageSize = 20;
int this_Page;
if (Request.QueryString["Page"] != null)
this_Page = Convert.ToInt32(Request.QueryString["Page"]);
else
this_Page = 1;
SQLpaged.CurrentPageIndex = this_Page - 1;
Label1.Text = "当前页:" + this_Page.ToString() + "/" + SQLpaged.PageCount;
if (!SQLpaged.IsFirstPage)
HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(this_Page - 1);
if (!SQLpaged.IsLastPage)
HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(this_Page + 1);
DataList1.DataSource = SQLpaged;
DataList1.DataBind();
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询