473,396 Members | 1,965 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,396 software developers and data experts.

Datalist refresh

Hi folks,

This seems to have been asked quite a bit but the solutions either dont
pertain to my case or the only response is to supply code. So here's
the question and the code is at the bottom.

I have a datalist which is displaying images in a gallery. Each image
has a pair of buttons to promote or demote the image in the list.

A little explanation about the code. The back end database contains two
tables Image and Gallery. Image contains a path to the image, an unique
ID a foreign key to the Gallery table to determine gallery membership
and an integer sequence number to determine the order it appears within
a gallery.

GalleryQuery is a class with a number of static methods that perform
operation on the backend sql server database. I'll refer to it as GQ in
the following for brevity

GQ.GetMinimumSequenceNumber gets the lowest sequence number for a given
gallery

GQ.GetMaximumSequenceNumber gets the highest sequence number for a
given gallery

GQ.GetSequenceNumber gets the sequence number for a specific image

GQ.PromoteImage swaps the sequence number of the chosen image with the
one above.

GQ.DemoteImage swaps the sequence number of the chosen image with the
one below

All of the above works as expected and if I check the backend database
after clicking a promote or demote button the relevent switch has
occured. Reviewing the page shows the switch has occured, however I
can't find a way of making the refresh occur without doing a
response.redirect or server.transer back to the same page.
Unfortunately there are other controls on the page that lose their
state as a result.

I'm assuming that some thing is required at the points marked // ??? in
the code.

Any help greatly appreciated.

protected void CommandFunction(object source, DataListCommandEventArgs
e) {
int gallery = int.Parse(lstGallery.SelectedValue);
int min = GalleryQuery.GetMinimumSequenceNumber(gallery);
int max = GalleryQuery.GetMaximumSequenceNumber(gallery);
int current =
GalleryQuery.GetSequenceNumber(int.Parse(e.Command Argument.ToString()),
gallery);
int currentImage = int.Parse(e.CommandArgument.ToString());

if (e.CommandName == "MoveUp") {
if (current min) {
GalleryQuery.PromoteImage(currentImage, gallery);
// ???
}
} else if (e.CommandName == "MoveDown") {
if (current < max) {
GalleryQuery.DemoteImage(currentImage, gallery);
// ???
}
}
}

Oct 10 '06 #1
2 4286
if you change the database, you need to rebind the datalist

-- bruce (sqlwork.com)

"Simon Rigby" <go****@simonrigby.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi folks,

This seems to have been asked quite a bit but the solutions either dont
pertain to my case or the only response is to supply code. So here's
the question and the code is at the bottom.

I have a datalist which is displaying images in a gallery. Each image
has a pair of buttons to promote or demote the image in the list.

A little explanation about the code. The back end database contains two
tables Image and Gallery. Image contains a path to the image, an unique
ID a foreign key to the Gallery table to determine gallery membership
and an integer sequence number to determine the order it appears within
a gallery.

GalleryQuery is a class with a number of static methods that perform
operation on the backend sql server database. I'll refer to it as GQ in
the following for brevity

GQ.GetMinimumSequenceNumber gets the lowest sequence number for a given
gallery

GQ.GetMaximumSequenceNumber gets the highest sequence number for a
given gallery

GQ.GetSequenceNumber gets the sequence number for a specific image

GQ.PromoteImage swaps the sequence number of the chosen image with the
one above.

GQ.DemoteImage swaps the sequence number of the chosen image with the
one below

All of the above works as expected and if I check the backend database
after clicking a promote or demote button the relevent switch has
occured. Reviewing the page shows the switch has occured, however I
can't find a way of making the refresh occur without doing a
response.redirect or server.transer back to the same page.
Unfortunately there are other controls on the page that lose their
state as a result.

I'm assuming that some thing is required at the points marked // ??? in
the code.

Any help greatly appreciated.

protected void CommandFunction(object source, DataListCommandEventArgs
e) {
int gallery = int.Parse(lstGallery.SelectedValue);
int min = GalleryQuery.GetMinimumSequenceNumber(gallery);
int max = GalleryQuery.GetMaximumSequenceNumber(gallery);
int current =
GalleryQuery.GetSequenceNumber(int.Parse(e.Command Argument.ToString()),
gallery);
int currentImage = int.Parse(e.CommandArgument.ToString());

if (e.CommandName == "MoveUp") {
if (current min) {
GalleryQuery.PromoteImage(currentImage, gallery);
// ???
}
} else if (e.CommandName == "MoveDown") {
if (current < max) {
GalleryQuery.DemoteImage(currentImage, gallery);
// ???
}
}
}

Oct 10 '06 #2
doh. I cant believe I missed that. Moral of the story is stop trying to
multi task. I should know as a male that doesn't work.

Thanks Bruce (I'll be in the corner)
bruce barker (sqlwork.com) wrote:
if you change the database, you need to rebind the datalist

-- bruce (sqlwork.com)

"Simon Rigby" <go****@simonrigby.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi folks,

This seems to have been asked quite a bit but the solutions either dont
pertain to my case or the only response is to supply code. So here's
the question and the code is at the bottom.

I have a datalist which is displaying images in a gallery. Each image
has a pair of buttons to promote or demote the image in the list.

A little explanation about the code. The back end database contains two
tables Image and Gallery. Image contains a path to the image, an unique
ID a foreign key to the Gallery table to determine gallery membership
and an integer sequence number to determine the order it appears within
a gallery.

GalleryQuery is a class with a number of static methods that perform
operation on the backend sql server database. I'll refer to it as GQ in
the following for brevity

GQ.GetMinimumSequenceNumber gets the lowest sequence number for a given
gallery

GQ.GetMaximumSequenceNumber gets the highest sequence number for a
given gallery

GQ.GetSequenceNumber gets the sequence number for a specific image

GQ.PromoteImage swaps the sequence number of the chosen image with the
one above.

GQ.DemoteImage swaps the sequence number of the chosen image with the
one below

All of the above works as expected and if I check the backend database
after clicking a promote or demote button the relevent switch has
occured. Reviewing the page shows the switch has occured, however I
can't find a way of making the refresh occur without doing a
response.redirect or server.transer back to the same page.
Unfortunately there are other controls on the page that lose their
state as a result.

I'm assuming that some thing is required at the points marked // ??? in
the code.

Any help greatly appreciated.

protected void CommandFunction(object source, DataListCommandEventArgs
e) {
int gallery = int.Parse(lstGallery.SelectedValue);
int min = GalleryQuery.GetMinimumSequenceNumber(gallery);
int max = GalleryQuery.GetMaximumSequenceNumber(gallery);
int current =
GalleryQuery.GetSequenceNumber(int.Parse(e.Command Argument.ToString()),
gallery);
int currentImage = int.Parse(e.CommandArgument.ToString());

if (e.CommandName == "MoveUp") {
if (current min) {
GalleryQuery.PromoteImage(currentImage, gallery);
// ???
}
} else if (e.CommandName == "MoveDown") {
if (current < max) {
GalleryQuery.DemoteImage(currentImage, gallery);
// ???
}
}
}
Oct 10 '06 #3

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

Similar topics

2
by: Martin Wulfe | last post by:
I want to use a connection to an existing MS Access database, but I want to be able to change which table is used to fill the datalist, using VB6, at run time by late binding the datalist to the...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
2
by: Vadivel Kumar | last post by:
I have one datalist which contains one item template. In that, iam printing a value taken from the sql table and one check box. Now, the user will select some checkbox and press a button and that...
2
by: Jules_Anime | last post by:
Is it possible to create an onclick event which is attached to individual datalist items? I have a Datalist with some details on employees, and when you click on one we would like to open a new...
1
by: schapopa | last post by:
Hi, I have nested datalist and I have some events that work, but I cannot find out how to refresh child and parent datalist after executing events on the child datalist. My childdatalist is an...
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: H5N1 | last post by:
Hello everybody I'm stuck for a long time with the following problem, so I will be really gratefull if you could help me a bit: I have a GridView nested in DataList (it's located in DataList's...
0
by: AleXmanFree | last post by:
Hi, I have this kind of problem, In my asp.net page i use DataList and user control that is repeated in DataList. This user control has in it a checkbox , so everytime user clicks on checkbox...
8
lee123
by: lee123 | last post by:
i have a book i have bought from amazon.com called "visual basic 6.0 advanced topics" and in one of the examples it has something i have been trying to figure out for awhile it has a datalist and a...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.