I have a gridview which has 4 columns, each holding an ImageButton in a templateField column. When I click on one of these image buttons the clicked upon image is displayed in Image1 using GridView1_RowCommand and this works fine.
However, when I click on one of the page numbers on the gridview the Image1 control resets to its original state and loses its ImageUrl.
I have a form with several controls. I'm trying to read from database and navigating through single record per page. I'm displaying a single record but not navigating through. My customerID field is the primarykey. But there are gaps btw records (1,2,5,6,10...etc). Some of them were deleted.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim myReader As SqlDataReader Dim myConnection = New SqlConnection("server=myPCSQLEXPRESS; database=CustomersDB; uid=myPC est; Password=; Trusted_Connection=yes") myConnection.Open() Dim myCommand = New SqlCommand("SELECT * FROM Customers", myConnection) Dim intFirstRecord As Integer = CInt(myCommand.ExecuteScalar()) myReader = myCommand.ExecuteReader() If myReader.Read Then lblCustomerID.Text = myReader("customerID") lblCustomerName.Text = myReader("CustomerName") End If myReader.Close() myConnection.Close() currentRecord = lblCustomerID.Text End Sub
Sub Next_OnClick(ByVal sender As Object, ByVal e As System.EventArgs) Dim myCommand As SqlCommand Dim myConnection As SqlConnection Dim myReader As SqlDataReader myConnection = New SqlConnection("server=myPCSQLEXPRESS; database=CustomersDB; uid=myPC est; Password=; Trusted_Connection=yes") myConnection.Open() myCommand = New SqlCommand("SELECT TOP 1 customerID, CustomerName FROM Customers WHERE customerID > @customerID", myConnection) myCommand.Parameters.Add("@customerID", SqlDbType.Int, 5).Value = currentRecord myReader = myCommand.ExecuteReader()
If myReader.Read Then lblCustomerID.Text = myReader("customerID") lblCustomerName.Text = myReader("CustomerName") End If myReader.Close() myConnection.Close() End Sub
I'm being able to read first record. If I click Next button, my page goes to next record for only once. If i click several times, nothing happens. Does not go to next available records.
Problem: it will sort and paging correctly but when after change a page, it will not display the corrected sorted order.
Protected Sub PFTGridView_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles PFTGridView.PageIndexChanging Dim PFTObj As New PFT Dim PFTDST As New Data.DataSet
I have a need to add a new report to my page, the differnent parts of the page are all using a objectdatasource to populate the data. The new report because of all the data being returned i have started to use a repeater and a table in the ItemTemplate. Just binding the objectdatasource to the repeater works fine, but returns all the records and causes the page to be very long. I found this link for adding paging to repeater, but its setup different than what i have
[URL]
Is there any way to use what i have already and add paging to the repeater?
so instead of a datasource control, I have a Data Access class that I'm using to populate the ListviewI added a datapager and everything pretty much works until I hit the first or last button. Then, I get the following error: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>Also, Something was mentioned about ClientScriptManager.RegisterForEventValidation - - couldnt' really find an implementationI tried setting:EnableEventValidation="false", but then, all I got was squirelly interaction with all the numbered links (sometimes having to double click them, etc) - no matter what I tried from there on out, even when I removed the enableEventValidation property altogether.
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.
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'd like to implement a custom paging template for my formview that displays numeric paging as well as next/previous buttons. The pre-defined templates only appear to have numeric first last as an option. Can anyone recommend a good article that covers this?
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 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
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 form called default.aspx which has a form with user information. In addition to this, I have an iFrame on the same page that displays a page Secondary-Form.aspx that has a few additional dynamic data fields. I need to do two things.
1. I need to pass the parent form data in real time to the iFrame page to refresh its content and modify it's fields accordingly. Example: If the user submits their Vehicle Choice as Car on parent form, the form item in iFrame will display a radio button that says Honda, and if the user submits their Vehicle Choice as MotorCycle in the parent page, the iFrame will display Harley Davidson as the radio button choice
2. The submit button is on the parent page. I want both pieces of this information (from the parent page, as well as iFrame selection) to be passed to a server side ASPX page to process this information.the default.aspx and Secondary-Form.aspx files are located on different domains.
I had implemented the Ajax timer control to update Gridview data(along with Progress bar inside Gridview) after some interval of time.Below is the full code:
HMTL:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <%--style & Script for progress bar in Gridview --%> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link href="css/jquery-ui.css" rel="stylesheet" />
I currently have a GridView control on my aspx page with paging enabled and I need to loop through the entire row collection/count to process the selected records. With my current code, it will only loop through the current page of GridView row.
foreach (GridViewRow data in grid.Rows) { //here is my code }
using above code i am able to print gridview directly without hidden fields.after added to hiddenfields to gridview , hiddenfield values are visible for printing.after i am using gridview.colums[i].visible=false column not visible while printingproblem is after print the gridview not visible whatever my columns set visible false.Example:at printing time i am set checkbox visible false, after printing i want reload same page with checkbox but check box not visible after printing gridview
I have a simple contact info webform with some validation rules developed in VS2010 that inserts a row in a SQL 2005 Express db.
However it does not always insert a row. (does for me !) There are no errors reported either in the browser or in the event log.
how I can narrow down the cause?
My code is faily simple. Basically the button calls the Insert command in the SqlDatasourcce , as generated through VS I do have one piece of code that forwards the user to a new page once the form is fillied in.