Also the gridview 1 and 2 the datasource is an SqlDataSource.
but that didnt work . also tried some things in pageindexchanged and pageindexchanging but still no efect :(. and also tried with enableviewstate = false / true on both gridviews with diferent combinations, but still no luck.
the code works only when i have allowpaging = false, or when im on the first page of the gridview (for the first time) is that the number of coments is pasted into the label.
I have a web user control with DataList control in it. In my .aspx page, I have a report header, an empty panel as a place holder, a report footer.In my .aspx.vb file, I'll loop through a list of departments. Within each department, I'll load a label to display the department name and the user control for the data, and add both the label and user control to the panel. So there are two variables: the number of departments and the number of records in a user control.
Now I need to display the current page number and the total page number in the report footer. Is it doable? How? I'm thinking of this approach: declare a page variable count, count the number of department name labels and the number of records in a user control. When the total count reaches a number, such as 20, I'll break the page. This way, I can get the the page current number and the total number of pages. But how to add a page break to an asp.net page?
In my database m having 1000 record and I want to display 10 record on each page on gridview so every time it fetch 1000 record so while page loading it is quite time consuming ..
I am trying to figure out why it won't display the other results when I click on the second and third links created by enabling the paging option the gridview control. it wasn't displaying properly.. also it may not make a lot of sense.. I'm a PHP programmer... I'm learning asp.net as part of a class and we're instructed to use the drag-and-drop method so forgive me, my asp.net skills are lacking and I am having a hard time learning it. Anyway I'm reposting the current code.. hopefully it will display properly this time. Here's the code for default2.aspx..
I have a datalist and want the results paged I have written a pager.ascx page and have an aspx and aspx.cs page to display the results. I have a stored procedure to pull the data out of the database and a class to talk between the stored procedure and presentation controls I have the pager being displayed when the results get over the limit I have set to 10 in the web.config file but when i click on the next link to display the next page of results it doesn't do anything. my aspx page is
<uc1:Pager ID="topPager" runat="server" Visible="False" /> <asp:DataList ID="newsList" runat="server" CssClass="List" align="center"> <ItemStyle CssClass="ItemList" /> <ItemTemplate> <h2><%# Eval("Title") %></h2> <p>Posted <%# Eval("Date") %></p> <p><%# Eval("News").ToString().Replace(" ", "<br />") %></p> </ItemTemplate> </asp:DataList> <uc1:Pager ID="bottomPager" runat="server" Visible="False" /> my aspx.cs page is protected void Page_Load(object sender, EventArgs e) { // Retreive page from the query string string page = Request.QueryString["Page"]; if (page == null) page = "1"; // How many pages of posts int howManyPages = 1; // pager links format string firstPageUrl = ""; string pagerFormat = ""; //DataAccess.GetNews returns a DataTable object containing news data which is read into datalist newsList.DataSource = DataAccess.GetNews(page, out howManyPages); // Bind the data to the data source newsList.DataBind(); // have the current page as interger int currentPage = Int32.Parse(page); // Display pager controls topPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, false); bottomPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, true); } my pager.ascx page is <p> Page <asp:Label ID="currentPagelabel" runat="server" /> of <asp:Label ID="howManyPageLabel" runat="server" /> | <asp:HyperLink ID="previousLink" runat="server">Previous</asp:HyperLink> <asp:Repeater ID="pagesRepeater" runat="server"> <ItemTemplate> <asp:HyperLink ID="hyperlink" runat="server" Text='<%# Eval("Page") %>' NavigateUrl='<%# Eval("Url") %>' /> </ItemTemplate> </asp:Repeater> <asp:HyperLink ID="nextLink" runat="server">Next</asp:HyperLink> </p> my pager.aspx.cs page is using System; // Simple struct that represents a (page number, url) association public struct PageUrl { private string page; private string url; // Page property definition public string Page { get { return page; } } // Url property definition public string Url { get { return url; } } // Constructor public PageUrl(string page, string url) { this.page = page; this.url = url; } } // The pager control public partial class UserControls_Pager : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } // Show the pager public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages) { // Display paging controls if (howManyPages > 1) { // make the pager visable this.Visible = true; // Display the current page currentPagelabel.Text = currentPage.ToString(); howManyPageLabel.Text = howManyPages.ToString(); // Create the Previous link if (currentPage == 1) { previousLink.Enabled = false; } else { previousLink.NavigateUrl = (currentPage == 2) ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1); } // Create the Next link if (currentPage == howManyPages) { nextLink.Enabled = false; } else { nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1); } // Create the page links if (showPages) { // The list of pages and their URLs as an array PageUrl[] pages = new PageUrl[howManyPages]; // Generate (page, url) elements pages[0] = new PageUrl("1", firstPageUrl); for (int i = 2; i <= howManyPages; i++) { pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i)); } // Do not generate a link for current page pages[currentPage - 1] = new PageUrl((currentPage).ToString(), ""); // Feed the pages to the repeater pagesRepeater.DataSource = pages; pagesRepeater.DataBind(); } } } } my class file is // Retreive the list of news posts public static DataTable GetNews(string pageNumber, out int howManyPages) { // Get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // Set the stored procedure name comm.CommandText = "GetNews"; // create a new parameter for page number DbParameter param = comm.CreateParameter(); param.ParameterName = "@PageNumber"; param.Value = pageNumber; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter for products per page param = comm.CreateParameter(); param.ParameterName = "@PostsPerPage"; param.Value = PlatiumMindProductionsConfiguration.PostsPerPage; param.DbType = DbType.Int32; comm.Parameters.Add(param); param = comm.CreateParameter(); param.ParameterName = "@HowManyPosts"; param.Direction = ParameterDirection.Output; param.DbType = DbType.Int32; comm.Parameters.Add(param); // Execute the stored procedure and saven the results in a DataTable DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // Calculate how many pages of posts and set the out parameter int howManyPosts = Int32.Parse(comm.Parameters["@HowManyPosts"].Value.ToString()); howManyPages = (int)Math.Ceiling((double)howManyPosts / (double)PlatiumMindProductionsConfiguration.PostsPerPage); // return the page of posts return table; } my stored procedure is ALTER PROCEDURE [dbo].[GetNews] (@PageNumber INT, @PostsPerPage INT, @HowManyPosts INT OUTPUT) AS -- Declare a new table DECLARE @News TABLE (RowNumber INT, NewsID INT, Title NVARCHAR(50), Date DATETIME, News NVARCHAR(MAX)) -- Populate the table with the complete list INSERT INTO @News SELECT ROW_NUMBER() OVER (ORDER BY NewsID desc), NewsID, Title, Date, News FROM News -- return the total number of posts SELECT @HowManyPosts = COUNT(NewsID) FROM News -- extract the request page of posts SELECT NewsID, Title, DATE, News FROM @News WHERE RowNumber > (@PageNumber - 1) * @PostsPerPage AND RowNumber <= @PageNumber * @PostsPerPage
I have a datalist inside 1 datalist.In the first datalist i am binding the "advertisement posted" date field from sql server. In the second datalist i am binding the ads posted on that date using an object datasource. my pro is, i need to show a total of 100 ads in one page. This should not depend on the date. Total 100 postings in the page. For example
Todays date (02/25/2010) 50 postings yesterdays date (02/24/2010)
if 75 postings are there,
50 postings
it should display only 50 postings under yesterday's date remaining 25 postings should display in next page(paging) with the format like this
yesterdays date (02/24/2010) remaining 25 postings (02/23/2010) 75 postings
we have a classic ASP Webpage for displaying reporting data.
The process is following:
user inputs reporting criteria reporting criteria are passed to a method in a VB6 DLL containing the reporting business logic (generating a dynmic sql statement) VB6 DLL method returns xml data xml data are displayed with xsd transformation 150.000 datarows are displayed in some seconds (less than 10 seconds maybe) Now we want to extend this reporting function and decided to use asp.net (2.0) So I have written a little prototyp application with a SqlDataSource Object and a GridView Control.
A table with less data (about 100 or so) are displayed quickly.
But a view with about 150.000 datarows needs about 2 minutes and ended with a OutOfMemoryException!
The request of the customer is definitvely to display the data on one page like in the old classic asp application!
I want to display 2 levels of listview, where outer listview has a datapager with 1 inner listview per page. The code is:
[Code]....
Then I bound outer listview with data in page_load(), which will invoke ExerciseBound(). It work fine for 1st page. The code is:
[Code]....
When I click on 2nd page, it will invoke ChangeExercise(). The code is:
[Code]....
Suppose it will invoke ExerciseBound() again and display 2nd listviewitem, but it fails to invoke ExerciseBound(). I change ChangeExercise() to
[Code]....
But PagePropertiesChangingEventArgs does not contain ListViewDataItem. Any thought? Is there a way to save ListViewDataItem in ExerciseBound() so that it can be accessed in ChangeExercise()? Or is there other way to access ListViewDataItem from ListView class directly?
I have a Gridview all setup and even though I have the paging working it takes select the page twice in order to switch the page. Basically my code is as follows:
Is there a way to use the GridView paging and having the links not use JavaScript. So that when you click on the page number 5 (for example) that link is a hyperlink.
I have a two webpages,in my first webpage i have gridview with 8 pages(paging) and four coloumns.In fourth coloumn i have a link button to redirect tosecond webpage ,now i am in gridview 4 th page(paging) then i clicked the link button and move to second second webpage.
second webpage contain one button that will redirect to first webpage.if i come from second webpage to first webpage the gridview paging get reset.but i want to be on gridview 4th page(paging).
I have a web page and a Tabcontainer in it, and in my tabcontainerthere is a Gridview , in below there is my code that i want if i change one filed to trure, that row become pink,and it works correctly, but now i want to have the number of the page of the last pink row in my Gridview,and keep it in a global variable , and the next time when i open my web page and come to that Tab, that page of the gridview be appear(the page of the last pink row), not the first page of it.
I would like to inquire about the delete the data in gridview with automatic number parameter ..when I edit a field with auto parameter number, how do I delete a field that does not automatically sort ..ex:
1. ROBERT 2. EMILIA 3. JOSE
When I remove the column to 2 EMILIA, then display in gridview 1. ROBERT 3. JOSE.
Coding that I got when I remove emilia then display in gridview 1.ROBERT 2.JOSE .. (sequence automatically)
private void Bindemptydt() { //Declare a datatable for the gridview DataTable dt = new DataTable(); //Add Columns to the datatable dt.Columns.Add("COLUMN"); dt.Columns.Add("TEXT");
im not sure why but my gridview seems to have stopped working in all areas of Editing, Deleting, Sortinging and i cant click the page number to switch between pages.Ive looked up numerous tutorials and on forums and still cant seem to find a solution that works for me. I have the edit delete sorting and paging check boxes selected.
When i click on any of the links nothing happens. not even a refresh.