Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Refreshing a DataList

Reply
Thread Tools

Refreshing a DataList

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      01-03-2007
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

http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Goofy
Guest
Posts: n/a
 
      01-03-2007

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" <> wrote in message
news:%...
>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
>
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net 1 08-04-2006 01:13 PM
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net Web Controls 0 08-03-2006 12:29 PM
GridView nested in DataList - refreshing corresponding DataList row after updating GridView row H5N1 ASP .Net 0 04-26-2006 11:41 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
RE: Refreshing DataList through user control =?Utf-8?B?Q2hyaXMgRmluaw==?= ASP .Net 0 09-03-2004 07:21 PM



Advertisments
 



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