Ben bu kod satırında bir hata olsun düzeltmek için nasıl bilmiyorum:Bir hata alıyorum ve bunu
i kullanmak çağrı amaçlaCurrentPage = FillRepeater() – 1;
PagedDataSource
sınıfı için kullanılan aynı sınıftır diğer databound kontrollerinde çağrı. FillRepeater()
işlevinde, PagedDataSource
sınıfının nesnesini oluşturdum ve bazı yöntemlerini kullandım. Bu basit özellikten sonra geçerli sayfa değerini aşağıdaki gibi almak için kullanılır. Bu sadece:
- Veri sayfasında
- mevcut durumunu saklamak için
viewstate
kullanır Ve ayrıca Tıklama etkinliğini Birincisi, Son Önceki ve sonraki sayfayı aldığı linkbutton işlevsellik katacak.public partial class ExamPage : System.Web.UI.Page { SqlConnection con; string query; public ExamPage() { con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); } protected void Page_Load(object sender, EventArgs e) { } private int FillRepeater() { query = "select top 10 Question,Option1,Option2,Option3,Option4 from Questions"; SqlCommand cmd = new SqlCommand(query, con); con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.AllowPaging = true; pds.PageSize = 8; int count = pds.PageCount; pds.CurrentPageIndex = CurrentPage; if (pds.Count > 0) { lbtnPrev.Visible = true; lbtnNext.Visible = true; lbtnFirst.Visible = true; lbtnLast.Visible = true; lblStatus.Text = "Page " + Convert.ToString(CurrentPage + 1) + "of" + Convert.ToString(pds.PageCount); } else { lbtnPrev.Visible = false; lbtnNext.Visible = false; lbtnFirst.Visible = false; lbtnLast.Visible = false; } lbtnPrev.Enabled = !pds.IsFirstPage; lbtnNext.Enabled = !pds.IsLastPage; lbtnFirst.Enabled = !pds.IsFirstPage; lbtnLast.Enabled = !pds.IsLastPage; Repeater1.DataSource = pds; Repeater1.DataBind(); return count; } public int CurrentPage { get { object obj = this.ViewState["_CurrentPage"]; if (obj == null) { return 0; } else { return (int)obj; } } set { //set in viewstate the current page number this.ViewState["_CurrentPage"] = value; } } protected void lbtnPrev_Click(object sender, EventArgs e) { CurrentPage -= 1; FillRepeater(); } protected void lbtnNext_Click(object sender, EventArgs e) { CurrentPage += 1; FillRepeater(); } protected void lbtnFirst_Click(object sender, EventArgs e) { CurrentPage = 0; FillRepeater(); } protected void lbtnLast_Click(object sender, EventArgs e) { CurrentPage = FillRepeater() – 1; FillRepeater(); } }
Ben sözdizimi hatası çalışma zamanı değil hatası alıyorum ama bunu çözmek için nasıl bilmiyorum: Aşağıda
Kod olduğunu. Ben hata, doğrultusunda
Aldığınız hatayla ilgili daha fazla bilgiyi paylaşır mısınız? Hat numarası, hata tipi, vb? – nhouser9
Bir şey yanlış '' ', onun eksi işareti değil. Değiştirin. – Guy