We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem(DataList)

Thread ID:

Created:

Updated:

Platform:

Replies:

40629 Feb 8,2006 02:04 PM UTC Feb 11,2006 01:04 PM UTC ASP.NET Web Forms (Classic) 2
loading
Tags: FAQ
Nada Adel
Asked On February 8, 2006 02:04 PM UTC

hey there, In the FAQ of the DataList there was this Question: How to do Paging in DataList? I wrote the exact code in my application but the "previous" and "Next" LinkButtons are not working I don''t know why...Here''s the code..Plz anyone try it and tell me wht''s missing?? <%#DataBinder.Eval(Container.DataItem, "ProductID").ToString()%> <%#DataBinder.Eval(Container.DataItem, "ProductName").ToString()%>
<< >>
C# int intStart ; SqlConnection cn ; SqlDataAdapter da ; DataSet ds ; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!Page.IsPostBack ) { ViewState["Start"] = 0; bindList(); } } void bindList() { cn = new SqlConnection("server=localhost;uid=sa;pwd=;database=northwind"); da = new SqlDataAdapter("Select * from Products ", cn); ds = new DataSet(); intStart = (int)ViewState["Start"]; ViewState["pageSize"] = 14; da.Fill(ds, intStart,(int) ViewState["pageSize"], "Table"); DataList1.DataSource = ds; DataList1.DataBind(); } private void lnkPrevious_Click(object sender, System.EventArgs e) { intStart = (int) ViewState["Start"] -(int) ViewState["pageSize"]; ViewState["Start"] = intStart; if (intStart <= 0 ) { ViewState["Start"] = 0; } bindList(); } private void lnkNext_Click(object sender, System.EventArgs e) { int dlistcount = DataList1.Items.Count; intStart = (int) ViewState["Start"]+(int) ViewState["pageSize"]; ViewState["Start"] = intStart; if ( dlistcount < (int)ViewState["pageSize"] ) { ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["pageSize"]; } bindList(); }

Administrator [Syncfusion]
Replied On February 11, 2006 12:50 PM UTC

Hi, Does it Not Paging or some behaviour Changes? Like the pageSize differs or something like that, paging was working for me when i tried , i was using dataset and update here , if you still have problem in this code Regards, Hari hey there, > >In the FAQ of the DataList there was this Question: > How to do Paging in DataList? >I wrote the exact code in my application but the "previous" and "Next" LinkButtons are not working I don''t know why...Here''s the code..Plz anyone try it and tell me wht''s missing?? > > > > > > > <%#DataBinder.Eval(Container.DataItem, "ProductID").ToString()%> > > <%#DataBinder.Eval(Container.DataItem, "ProductName").ToString()%> > > > > > > > > > > >
<< > > >> > >
> > > > > >C# > >int intStart ; > >SqlConnection cn ; > >SqlDataAdapter da ; > >DataSet ds ; > >private void Page_Load(object sender, System.EventArgs e) > >{ > > // Put user code to initialize the page here > > if(!Page.IsPostBack ) > > { > > ViewState["Start"] = 0; > > bindList(); > > } > >} > > > >void bindList() > >{ > > cn = new SqlConnection("server=localhost;uid=sa;pwd=;database=northwind"); > > da = new SqlDataAdapter("Select * from Products ", cn); > > ds = new DataSet(); > > intStart = (int)ViewState["Start"]; > > ViewState["pageSize"] = 14; > > da.Fill(ds, intStart,(int) ViewState["pageSize"], "Table"); > > DataList1.DataSource = ds; > > DataList1.DataBind(); > >} > > > >private void lnkPrevious_Click(object sender, System.EventArgs e) > >{ > > intStart = (int) ViewState["Start"] -(int) ViewState["pageSize"]; > > ViewState["Start"] = intStart; > > if (intStart <= 0 ) > > { > > ViewState["Start"] = 0; > > } > > bindList(); > >} > > > >private void lnkNext_Click(object sender, System.EventArgs e) > >{ > > int dlistcount = DataList1.Items.Count; > > intStart = (int) ViewState["Start"]+(int) ViewState["pageSize"]; > > ViewState["Start"] = intStart; > > if ( dlistcount < (int)ViewState["pageSize"] ) > > { > > ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["pageSize"]; > > } > > bindList(); > >} > > > > >

Administrator [Syncfusion]
Replied On February 11, 2006 01:04 PM UTC

Hi Adel, I could see the problem because of this line if ( dlistcount < (int)ViewState["pageSize"] ) { } ignore this line and then try , you should be able to continue with paging, I havent tried. if the above doesnt work ,Update here. Regards, Hari

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;