.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

DataPager Manual input From Listview Control

Posted By:      Posted Date: September 25, 2010    Points: 0   Category :ASP.Net

Hi There,

I've been trying to marry up the listview and the Data pager with my own, Database class that pulls the information from the database.

I can display the information ok no problem, fortunately this time I know what the problem is, but I cannot figure out a way around the problem.

In my Page_Load event I fill out the listview accordingly:


Dim mList As List(Of Object) = mDbase.Record.Items("SELECT TBLResults.ID, Draw, [Date], B1, B2, B3, B4, B5, B6, BB, Jackpot, Wins, Machine, BallSet FROM TBLResults, TBLMachine WHERE TBLResults.MachineID=TBLMachine.ID ORDER BY Draw", GetType(ResultItem))


     Me.ListView1.DataSource = mList





The problem lies in the postback, I need to figure out a way get the information as to what state the DataPager is in so I could update the Query accordingly.

I know there is a StartRowIndex avaialbe but this does not get updated in the Page_Load event.

Has anybody got any ideas?

View Complete Post

More Related Resource Links

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

Accessing Label Control In a listview using Javascript



I have a Button and Label nested inside a ListView.

When a User clicks the button i want the Label to display a specific value eg"Pass". Of course being a Listview the Label value will be relevant to the row the button was clicked on.

I want all this to happen on client side, but i am struggling to access the Label via my Javascript??

Any suggestions and examples Would be much appreciated..

Display a nested child ListView on PostBack while using DataPager on parent ListView


Hello ASP.NET community,

I am having trouble finding how to solve the following issue :

I am using nested listviews to display Sales and Sales details.

The main ListView displays General Information about Sales and the child ListView displays the detailed information about one sale. the child listview is shown only when the user clicks on a link (see included code, DataBind is made on PageLoad) :

ASPX Markup Code :

<asp:listview id="lvSales" runat="server" onitemdatabound="lvSales_ItemDataBound">
<table cellspacing="0" border="1" width="250" style="border-collapse:collapse;">
<tr runat="server" id="headerRow">
<th scope="col" style="width:30px;"></th>
<th scope="col">SaleNumber</th>
<tr id="itemPlaceHolder" runat="server" enableviewstate="true"/>
<tr id="row" runat="server">
<td style="text-align:center;"><asp:button id="btnShowHideDetails" runat="server" oncommand=&qu

Printer Friendly Page from a listview control


Hi guys,

I am working on a web form that displays the data from an access data source into a list view control. I need an advice on how to create , render a new page printer freindly .not buttons, controls,,, I have implemented a  java script function to select which records I want to view in the printable page but I cannot came up with any idea on how  to use this to create the printable help..


How to Delete from a SortedList using Listview Control

I'm new to Asp.net, and I looked at an example of using a listbox's selected index to delete from a sortedlist. I'd like to write something that would get the selected index from a different control, like a listview, and then delete from the sortedlist. I've read up on a few examples on how to bind data from a sortedlist to a listview, but I've not seen an example of how to get the index once the data is displayed! Can this be done? Thanks for any response!

Microsoft ListView Control 6.0 cannot correctly display multibyte characters when running on a 64 bi

With all the regional settings set to Russian and the OS being Russion the ListView Control 6.0 does not display the column headers correctly on the Windows Server 2008 64 bit OS. If we switch to using Microsoft ListView Control, version 5 the columns (text strings) are displayed correctly. I am concerned that using an earlier version is going to cause problems. Is there a better solution other than using version 5? Thanks!

Passing Id to a querystring in a Listview Control

I have tried almost evrything and nothing seems to work,,, I dont see errors but the code is not firing when I bind in the properties of the button control ,,nor the code behind., much help is appreciated,,aspx<LayoutTemplate>                <table id="Table1"cellpadding="0" cellspacing="0" style="border-right: #000000 thin solid; border-top: #000000 thin solid;                                    border-left: #000000 thin solid; border-bottom: #000000 thin solid; background-color: #FFFFFF; border-width: 1px;"                                    width="100%" align="center">        <tr>            <td>                    <b>Matching Providers </b>        

Find Control in ListView ItemTemplate

I want to pass the checked checkboxes value of my listview control to a second page so I can display the listview in this second page  with only those selected recordsthis is what I am have so far , but dont really know how to get it to work the desire way.. Code is working but I am afraid that chekcbox and listview values for my loop are not correctMuch help is appreciated!! page1 codeProtected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListView1.ItemDataBound        Dim recordsId As New List(Of String)        Dim chb As CheckBox = DirectCast(ListView1.FindControl("CheckBoxPrintProvider"), CheckBox)        For Each lvi As ListViewItem In ListView1.Items            ' Dim chb2 As CheckBox = DirectCast(lvi.FindControl("CheckBoxPrintProvider2"), CheckBox)            ' Check if the checkboxes are checked             ' If (chb.Checked Or chb2.Checked) Then            '  If chb.Checked Then        &nbs

Can't access a control in a listview layout template with codebehind

While running ItemDetabound upon load of a listivew, I am trying to access the text in a label of the LayoutTemplate of a different Listview.  It works fine if I try access the same labels under the same names if they are in the same listview, but not if they are in a different one.  It was working for a while, can't figure out what I changed, but now says that object doesn't exist.   Here is the html code for the labels: <LayoutTemplate> <table ID="Table2" runat="server" cellpadding="0" cellspacing="0"> <tr ID="Tr1" runat="server" style="padding-left: 0px"> <th ID="Th1" runat="server" style="text-align: left; white-space:nowrap; "> <asp:Label ID="Label1" runat="server">Label 1</asp:Label> </th> <th ID="Th2" runat="server" style="white-space:nowrap; width: 150px" >

(trying to) Create a Listview control

Hello, I am trying to create a Winform-based Listview that uses the Client Object Model for Sharepoint 2010 to display a folder's contents similar to how a user would see it in Sharepoint. My first problem was accessing the view (which I was able with help to do), however, I found that the names of the columns in the view did not match the object property names for the objects. I am wondering if there is a "proper" way to do implement this. I am thinking I should be using a CAML query to pull back the necessary fields in the documents list, something like: My to-do list for this process is: 1: Determine the View I should be using -- is there a CAML query for that? 2: pull back the view columns w/ proper object property names -- I have the view, but the view returns improper object property names 3: Query SP (given view columns) for all docs under a certain folder something like: <RowLimit>25</RowLimit><br/> <ViewFields><br/> ... my fields from the view query ...<br/> </ViewFields><br/> <Where><br/> <Eq><br/> <FieldRef Name='FileDirRef'/><Value Type='Text'>http://myserver/documents/somefolder</Value><br/> </Eq><br/> </Where> 4: Cycle through each of the Results of step 3, transferring the info into the listview.   So, that's

Exception caused by DataPager.SetPageProperties() on ListView (postback error)

 Hi, I have a issue with drives me crazy! I'm using the DataPager method SetPageProperties() to restore the current page in my listview after I navigated into a page related to a listview item. (I persist the current page in the session state) I display 10 items at a time, and there are 10 pages. Everything works perfectly for the first 100 items, .... but after I go beyond (to display pages 11 to 20), if I call SetPageProperties() to restore the proper "current" page, I cannot submit anymore anything without getting the following exception: An error has occurred because a control with id 'ctl00$ctl00$ContentPlaceHolder$ContentPlaceHolder1$m_ListViewSearchItems$lvProductsPager$ctl00$ctl10' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error. The exception refers to the DataPager sub-controls which are not rendered the same way for first pages (1 - 10) than (11 - 21); Is that because it expect then a "previous page" button? I don't quite know what to think about it. Does anyone have a clue?

URL Routing + DataPager control

hi all, we are using URL Routing so a path like http://www.mysite.com/news/Default.aspx would be output like http://www.mysite.com/news we have a data pager on the page that ties to the list view. the data pager when changing pages reverts the url back to the un-routed version (like http://www.mysite.com/news/default.aspx?page=2) how can i re-write this back to something more friendly for my app ideally it would be great to have it look sometihng like /news/page/2  i can use IIS 7's new re-write module - already using it to remove trailing slashes. thanks in advance, mcm  

Binding ListView Control Using MVVM

In this short post I will show you how you can bind the list view control and get the selected value of the list view control using MVVM pattern. For this post I have added one list view control which hold the grid view control in it view and when item is selected in the grid view the selected item is shown at the end of the screen. In the Image 1the selected items are not shown ( only the label fields are shown) but in the Image 2 when user click on any of the item the detail is shown.

ListView with DataPager

Hi, i use a ListView with DataPager but fail when change page in the DataPager because does nothing. Producto losProductos = new BLL.Producto(); ListView1.DataSource = losProductos.TraerTodos(); //List<Producto> ListView1.DataBind();   <asp:ListView ID="ListView1" runat="server"> <LayoutTemplate> <ul class="ulproduct"> <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> </ul> </LayoutTemplate> <ItemTemplate> <li> <table width="100%"> <tr> <td rowspan="3" class="style1"> <img class="img" src='<%# string.Format("/SirPet.com/img/productos/{0}.jpg", Eval("Codigo")) %>' alt='<%# Eval("Codigo")%>' height="90" width="60" /> </td> </tr> <tr> <td colspan="2">

Finding a control inside a ListView on a master page

I have a listview on a master page that ISN'T part of a content place holder that I want to fill in and disable if the user is already logged in. I have a label set up already which works fine. I'm just having problems accessing a Textbox by the name of "NameTextBox" in the InsertItem template of the listview.Here is the part of my codefile:Dim vCurrentUser As MembershipUser = Membership.GetUser() If Not vCurrentUser Is Nothing Then Dim pnl As Label = LoginView1.FindControl("Label1") pnl.Text = Page.User.Identity.Name Dim NameBox As TextBox = ListView1.InsertItem.FindControl("NameTextBox") NameBox.Text = Page.User.Identity.Name End IfI get a Object not found exception. What is the correct way to find a control inside a InsertItemTemplate and the correct Event to use?

Using HTML5 new input types with .NET TextBox control


Hi here's my problem.


I'm building a iPhone, iPad website I'd like to use the new HTML 5 input types: http://www.w3.org/TR/html-markup/input.number.html so a numeric keyboard will pop.


I'm using a ASP .NET TextBox :

<asp:TextBox ID

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend