Advertisement

02.23.2008 at 05:03PM PST, ID: 23187825
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

How do I bind data from SqlDb to a ListView & Binding Pagesize
Tags: asp.net
1. I need to populate ListView with the data from database from .vb ffile, not asp:SqlDataSource
2. i have no idea how to bind and implement Change Pagesize with DropDovnList
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
.aspx file  
 
  <div class="StatusMessage">
        <asp:Label ID="PageMessage" runat="server"></asp:Label>
    </div>
    
     <asp:DataPager ID="ProductListPagerSimple" runat="server" PagedControlID="ProductList" PageSize="5">
        <Fields>
            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
                ShowPreviousPageButton="False" />
            <asp:NumericPagerField />
            
            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
                ShowPreviousPageButton="False" />
                  
        </Fields>
    </asp:DataPager>
    
    
   <asp:DataPager ID="ProductListPager" runat="server" PagedControlID="ProductList" PageSize="5">
        <Fields>
            <asp:TemplatePagerField>
                <PagerTemplate>
                    Jump to a specific page:
                    <asp:DropDownList runat="server" ID="PageJump" AutoPostBack="true" 
                        onselectedindexchanged="PageJump_SelectedIndexChanged">
                    </asp:DropDownList>
                </PagerTemplate>
            </asp:TemplatePagerField>
        </Fields>
    </asp:DataPager>
    
   
    
     <asp:DataPager ID="ProductListPagerCombo" runat="server" PagedControlID="ProductList" PageSize="5">
        
        <Fields>
            <asp:NextPreviousPagerField FirstPageText="&lt;&lt;" ShowFirstPageButton="True" 
                ShowNextPageButton="False" ShowPreviousPageButton="False" />
            <asp:NumericPagerField />
            
            <asp:NextPreviousPagerField LastPageText="&gt;&gt;" ShowLastPageButton="True" 
                ShowNextPageButton="False" ShowPreviousPageButton="False" />
        </Fields>
        
    </asp:DataPager>
         <br />
         
         
         Change Pagesize
         <asp:DropDownList ID="ddlChangePagesize" runat="server">
            
             <asp:ListItem Selected="True">5</asp:ListItem>
             <asp:ListItem>7</asp:ListItem>
             <asp:ListItem>10</asp:ListItem>
             <asp:ListItem>12</asp:ListItem>
             <asp:ListItem>15</asp:ListItem>
             <asp:ListItem>22</asp:ListItem>
         </asp:DropDownList>
          &nbsp;
         <asp:Button ID="Button1" runat="server" OnClick="RePage" Text="Change Pagesize" />&nbsp;<br />
         <br />
        
 
    
    
    
    
    
    
    
    <asp:ListView ID="ProductList" runat="server"  DataSourceID="SqlDataSource1">
        <LayoutTemplate>
            <h3>Product Listing</h3>
            <blockquote>
                <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>                        
            </blockquote>
        </LayoutTemplate>
        
        <ItemSeparatorTemplate>
            <hr />
        </ItemSeparatorTemplate>
 
        <ItemTemplate>
        
            <h4><%#Eval("Naslov") %></h4>
            Available at <%#Eval("PostText")%> <br />
            dodano :  <%#Eval("Created")%>
            
        </ItemTemplate>
    </asp:ListView>
    
    
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DataAccessQuickStart %>"  
            SelectCommand="SELECT [IdPost], [UserID], [IdLang], [Created], [Naslov], [PostText], [Brojac], [ActivePost] FROM [ac_Posts] WHERE (([IdLang] = @IdLang) AND ([UserID] = @UserID)) ORDER BY [IdPost] DESC">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="IdLang" Type="Int32" />
                <asp:Parameter DefaultValue="1" Name="UserID" Type="Int32" />
                
            </SelectParameters>
            
        </asp:SqlDataSource>
    
           
----------------------------------------------------------------------------------------
.aspx.vb file
 
 Protected Sub ProductList_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductList.DataBound
 
        Dim currentPage As Integer = (ProductListPager.StartRowIndex / ProductListPager.PageSize) + 1
        Dim totalPages As Integer = ProductListPager.TotalRowCount / ProductListPager.PageSize
        PageMessage.Text = String.Format("You are viewing page {0} of {1}", currentPage, totalPages)
 
        'Populate the DropDownList if needed
        Dim ddl As DropDownList = CType(ProductListPager.Controls(0).FindControl("PageJump"), DropDownList)
        If ddl.Items.Count = 0 Then
            'Add a list item for each page
            For i As Integer = 1 To totalPages
                ddl.Items.Add(i.ToString())
            Next
 
            'Set the DDL to the appropriate page value
            ddl.Items.FindByValue(currentPage.ToString()).Selected = True
        End If
    End Sub
 
 
 
    Protected Sub PageJump_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
 
        Dim PageJumpDDL As DropDownList = CType(sender, DropDownList)
        Dim pageNo As Integer = Convert.ToInt32(PageJumpDDL.SelectedValue)
 
        Dim startRowIndex As Integer = (pageNo - 1) * ProductListPager.PageSize
 
        ProductListPager.SetPageProperties(startRowIndex, ProductListPager.PageSize, True)
 
    End Sub
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: goherceg
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: B
Views: 13
Translate:
Loading Advertisement...
02.25.2008 at 06:46AM PST, ID: 20975734

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 10:25AM PST, ID: 20977892

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 10:35AM PST, ID: 20977969

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 10:46AM PST, ID: 20978067

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 11:13AM PST, ID: 20978294

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 11:57AM PST, ID: 20978643

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 12:41PM PST, ID: 20979015

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 12:55PM PST, ID: 20979141

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 02:02PM PST, ID: 20979703

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.25.2008 at 06:46AM PST, ID: 20975734

Rank: Genius

What kind of file are you talking about reading?

Bob
 
02.25.2008 at 10:25AM PST, ID: 20977892
not file, maybe I didn't put it wright

I find this script here http://aspnet.4guysfromrolla.com/articles/021308-1.aspx, but that example is with Declatative dataBinding  "<asp:SqlDataSource". That what I need is binding in ListViewPaging.aspx.vb file.

I try to implement, as you can see, DataPager with id=dpChangePagesize with DropDownList called ddlChangePagesize. That don't work. What it a do wrong?



I'm sending you a sctipt that will give you a picture, just remove ".jpg" extension
 
ListViewPaging.aspx file
 
 
ListViewPaging.aspx.vb file
 
 
02.25.2008 at 10:35AM PST, ID: 20977969

Rank: Genius

So, now you mean that you want to define the SelectCommand for the SqlDataSource in the code-behind?

Bob
 
02.25.2008 at 10:46AM PST, ID: 20978067
yes
 
02.25.2008 at 11:13AM PST, ID: 20978294

Rank: Genius

Example:
1:
2:
3:
4:
5:
sqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
sqlDataSource1.SelectCommand = "SELECT MAX([news.id]) As 'highVal' FROM [news]" 
 
Dim sqlDataView As DataView = DirectCast(sqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView) 
Dim result As Integer = CInt(sqlDataView(0)(0)) 
Open in New Window
Accepted Solution
 
02.25.2008 at 11:57AM PST, ID: 20978643
thanks, that's working.
I have more quations.

How can I  access label in  ProductList_DataBound and view a value?
  Dim lblPostText As Label = CType(ProductList.Controls(0).FindControl("lblPostText"), Label)
        lblPostText.Text = (Left(("PostText"), 250))

This generate an error
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
-----------------------------------------------------------------------------------------------------------------------

Protected Sub ddlChangePagesize_SelectedIndexChanged procedure doesn't working. When you select 2, 5,10,20 ect. value of ddlChangePagesize is allvays 2 and ListView show 10 records.
How can I access PageSize of  ProductListPager, ProductListPagerCombo and dpChangePagesize DataPager in code behind.

 
02.25.2008 at 12:41PM PST, ID: 20979015

Rank: Genius

That, my friend, is another question, and you should only ask a single question, or this could quickly become a never-ending question.

Bob
 
02.25.2008 at 12:55PM PST, ID: 20979141
where I can find something about this subject on internet

so what is your suggestion, to open another question or ...
 
02.25.2008 at 02:02PM PST, ID: 20979703

Rank: Genius

Think about NamingContainer, since it is the one that you need to call FindControl from.

Using the NamingContainer Property to Determine a Control's Naming Container
http://msdn2.microsoft.com/en-us/library/txxbk90b(VS.80).aspx

Bob
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628