473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Refreshing a DataList

I have a DataList control that I want users to be able to sort the data in
by clicking 1 of 3 buttons. The function I have created to do this is as
follows:
Private Sub SortPoems(ByVal sortby As String)
Dim ratedpoems As New DataTable
Dim sqltext As String = "SELECT * FROM poemratings ORDER BY "

Select Case sortby
Case "title"
sqltext &= "title"
Case "rating"
sqltext &= "(totalpoints/timesrated),timesrated,title"
Case "timesrated"
sqltext &= "timesrated,(totalpoints/timesrated),title"
End Select
Dim dataadapterSelect As New System.Data.OleDb.OleDbDataAdapter(sqltext,
System.Configuration.ConfigurationManager.AppSetti ngs("connectionstring"))
dataadapterSelect.Fill(ratedpoems)
Me.datRatings.DataSource = ratedpoems
Me.datRatings.DataBind()
End Sub
When the page first loads, I call

Me.SortPoems("title")

from Page_Load, which works fine, but when I try to call it a second time
using one of the buttons it does not work. However, if I call it twice in
Page_Load, it does work when I call it with the buttons. Why is this? What
is it that calling it a second time in Page_Load does that allows me to call
it with the buttons? I am using Microsoft Access as my database, and I am
using ASP.NET 2.0. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 3 '07 #1
1 856

1.) When you say you cannot call it from one of the buttons, do you mean

a.) That the code is not executed
b) That the code is executed but does not work as expected.?

2.) If 1a) Then you need to look at the handler for the button , if 1b)
then you need to review if the DataList is being bound somehere else in you
code .
3.) The order the events fire in are important, look at your event handlers
for the page events and make sure you are not rebinding the control to
another or an unpopulated data source.
HTH


"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I have a DataList control that I want users to be able to sort the data in
by clicking 1 of 3 buttons. The function I have created to do this is as
follows:
Private Sub SortPoems(ByVal sortby As String)
Dim ratedpoems As New DataTable
Dim sqltext As String = "SELECT * FROM poemratings ORDER BY "

Select Case sortby
Case "title"
sqltext &= "title"
Case "rating"
sqltext &= "(totalpoints/timesrated),timesrated,title"
Case "timesrated"
sqltext &= "timesrated,(totalpoints/timesrated),title"
End Select
Dim dataadapterSelect As New
System.Data.OleDb.OleDbDataAdapter(sqltext,
System.Configuration.ConfigurationManager.AppSetti ngs("connectionstring"))
dataadapterSelect.Fill(ratedpoems)
Me.datRatings.DataSource = ratedpoems
Me.datRatings.DataBind()
End Sub
When the page first loads, I call

Me.SortPoems("title")

from Page_Load, which works fine, but when I try to call it a second time
using one of the buttons it does not work. However, if I call it twice in
Page_Load, it does work when I call it with the buttons. Why is this? What
is it that calling it a second time in Page_Load does that allows me to
call it with the buttons? I am using Microsoft Access as my database, and
I am using ASP.NET 2.0. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Terry Cox, MCSD | last post by:
I have this problem throughout a site I am designing. The Update, Edit, and Insert commands all seem to re-databind properly, but the the OnDeleteCommand only processes. The deleted item remains on...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: H5N1 | last post by:
Hi there My problem is that in when I update GridView row, which is nested into DataList control, I want to refresh also DataList in which the GridView is nested, since after update, trigger in...
1
by: Nathan Sokalski | last post by:
I have a DataList control that I want users to be able to sort the data in by clicking 1 of 3 buttons. The function I have created to do this is as follows: Private Sub SortPoems(ByVal sortby...
0
by: =?Utf-8?B?SmFtZXM=?= | last post by:
Hello. I have a drop down list (DDList) and a Data List (DataList) on a page. When I choose something from the Drop Down List (it lists States) the datalist changes to display all the people...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
17
lee123
by: lee123 | last post by:
I know this is a free site and the moderators or anybody don't have to answer if they don't want to.. but if there is someone who knows how to answer this question please help with this one. i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.