Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 21, 2009 01:33 AM by cramerhwood
Jul 12, 2006 05:44 PM|LINK
What problem are you guys adressing here?
I thought my problems were solved with:
SELECT top 5 [id], [itemdate], [title], [description], [photo]
WHERE itemdate <= GETDATE()
ORDER BY itemdate DESC
Jul 12, 2006 06:47 PM|LINK
Jul 12, 2006 09:24 PM|LINK
..... now I understand.
Indeed NewsList does not show any news before the projected date.
However in NewsView when I click on Next Article I still get to see the article before it's due.
Am I alone in this?
Jul 12, 2006 10:14 PM|LINK
You are not alone - the stored procedures NextAnnouncement and NextPrevAnnouncement both also have no logic in them to suppress items with dates in the future. As well, the logic in News_View where it decides if the next and previous links should be hot
is not quite right, it doesn't know if the link is hot until after you click it (click next until you get to the end, it will allow you one more click which does nothing before it makes the link disabled). This should be rewritten somehow.
I'm not motivated to work on this particular issue myself, but what I would probably do is something like make a single procedure which
-builds a temp list of viewable items where itemdate <= getdate()
-selects from temp the previous item id into a variable (null if we are at the first one) @prev
-selects from temp the next item id into a variable (null if we are at the last one) @next
-selects the item we want into a variable @item
then select bla, bla, bla,@prev, @next from announcements where id = @item
now we have all the info to make the page in one go
so in sqldatasource1_selected() we can set whether the next and previous links go anywhere.
If you don't want to do this, and your site depends heavily on being able to create news items that are hidden until the due date, then I would just remove the next/prev links from news_view, I don't think they are that useful, even if they are cool. They
also have this unpleasant side effect in that the URL does not change, so if you go to article 6 and then use the next link to move to article 7, and you bookmark the page, the bookmark will point to ... article 6. Kinda weird. Not so big an issue in the list
pages, but odd in a content page.
Jul 13, 2006 06:35 AM|LINK
Removing or hiding the linkbuttons is the way to go for me at this point. Cleans the page up quite nicely at the same go.
Perhaps in the future when I know a little bit more about this stuff I'll address it.
I wish everybody that is not motivated to tackle a problem would be so willing to desribe that same problem.
Jul 13, 2006 01:36 PM|LINK
Lex et al, isn't this problem solved by modifying the stored procedures to add an itemdate < GETDATE() condition?
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
ALTER PROCEDURE [whatever].[NextPrevAnnouncement]
@previd int output,
@nextid int output
/* SET NOCOUNT ON */
DECLARE @curr datetime
SELECT @curr = itemdate
WHERE (id = @id)
SELECT @previd= id
WHERE (itemdate < @curr OR
(itemdate = @curr) AND (id < @id))
ORDER BY itemdate ASC, id ASC
SELECT @nextid= id
WHERE (itemdate < GETDATE() AND
(itemdate > @curr OR
((itemdate = @curr) AND (id > @id))))
ORDER BY itemdate DESC, id DESC
You would have to modify NextAnnouncement and NextPrevAnnouncement this way. There was some related logic in the News_View.aspx that was broken. It had to do with next/previous clicks, and deciding which items were valid and
which not. See here for a description of the problem and a fix.
Jul 13, 2006 06:33 PM|LINK
Jul 29, 2006 05:34 PM|LINK
I just added the required field validator on top of the description textbox and it worked fine with me. Sample code below
ErrorMessage="Event description cannot be empty"
Jul 31, 2006 06:21 PM|LINK
Aug 05, 2006 07:19 AM|LINK