In the C# version of the Club Site when a user clicks "Add Event" will be directed to the add event page. If the user does not enter a description for the event, there's no validation for that field and it throws an error reporting
a invalid conversion attempt from a DBNull. I haven't found a permanent fix for this because I'm not familiar with the "FormView" control that contains it. A quick fix was that on page load, if the user is adding a new event, I set the text property of the
description text boxt to " " so that it is not null. If anyone knows a permafix for this, let me know.
I have implemented RequiredFieldValidator fields for all the things that I think are necessay in the database. You can also check each table via the Server Explorer so you know which fields are not allowed to be Null/Nothing.
I apologize if this bug has already been covered. I looked through the posts and could not find any threads about it so I decided to post what I discovered. Hope this helps.
To simulate:
1. log in as admin
2. navigate to events_list
3. click "List View"
4. click the green rollover button "Remove"
5. you are redirected to Events_Edit.aspx
6. The event is not removed.
Fix:
Under Begin News Item comment, under <asp:repeater...>, within <ItemTemplate>, and within <asp:panel ID=panel2...>, the line
This fix passes the correct parameter value to "action" that is defined in the events_edit.aspx. Until this fix, the logic in the events_edit.aspx page would fall through to the "Case Else" and land you at the event_edit instead of "removing" the event
and redirecting you back to events_list.aspx.
Below is the sub that the "action" value is passed to:
Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
'Initialize the fields
Dim action As Object = Request.QueryString("Action")
If Not action Is Nothing Then
Select Case LCase(CStr(action))
case "new"
'We are in new mode
FormView1.ChangeMode(FormViewMode.Insert)
Dim lp As LocationsPicker = CType(FormView1.FindControl("LocationPicker1"), LocationsPicker)
lp.LocationID = Nothing
Dim dp As DurationPicker = CType(FormView1.FindControl("dtpicker"), DurationPicker)
dp.startDateTime = Now
dp.endDateTime = Now.AddHours(3)
Dim slp As TextBox = CType(FormView1.FindControl("staticURLTextBox"), TextBox)
slp.Enabled = False
Case
"delete"
SqlDataSource1.Delete() /* This was origionally "Remove" and I changed to "Delete"
Response.Redirect("Events_list.aspx")
Case Else
'We are in edit mode
Dim cb As CheckBox = CType(FormView1.FindControl("CheckBox1"), CheckBox)
Dim surl As TextBox = CType(FormView1.FindControl("staticURLTextBox"), TextBox)
If Not surl.Text Is Nothing AndAlso surl.Text <> "" Then
cb.Checked = True
surl.Enabled = True
Else
surl.Enabled = False
End If
End Select
End If
End If
End Sub
junck --
All human actions have one or more of these seven causes: chance, nature, compulsion, habit, reason, passion, and desire.
Aristotle Greek critic, philosopher, physicist(384 BC - 322 BC)
I have the site up-and running, but when I try to add a News entry, and select a future date for the control that says ' The news article will not be visible to users until after this date.', this date doesn't
seem to be respected. If I add a news article to be displayed in the future, it still shows ALL the entries from both the home page as well as the news link.
In this case, it's the select statement in the sqldatasource on default.aspx, and the stored procedure PagedAnnouncementList, neither one does what the UI suggests it will do.
To fix, in both places, add 'itemdate <= getdate()' to the where clause, i.e.:
SELECT top 5 [id], [itemdate], [title], [description], [photo] FROM [Announcements]
WHERE itemdate <= GETDATE() ORDER BY itemdate DESC
There was some other problem with that sproc, I forget what exactly, so I had written a slightly different version of it:
ALTER PROCEDURE [dbo].[PagedAnnouncementList]
(
@pageNum INT = 1,
@PageSize INT = 10
)
AS
-- Set the page bounds
DECLARE @PageLowerBound int
DECLARE @PageUpperBound int
DECLARE @TotalRecords float
SET @PageLowerBound = @PageSize * (@pageNum - 1)
SET @PageUpperBound = @PageSize - 1 + @PageLowerBound
-- Create a temp table to put items in the order we want
CREATE TABLE #ItemIndex
(
IndexId int IDENTITY (0, 1) NOT NULL,
NewsId int
)
-- Insert into temp table
INSERT INTO #ItemIndex (NewsId)
SELECT a.id
FROM announcements a WHERE itemdate <= GETDATE() ORDER BY itemdate DESC, id DESC
-- Get the page we need from the ordered temp table
SELECT a.id, a.itemdate, a.title, a.description, a.photo FROM Announcements a
JOIN #ItemIndex i ON i.NewsId = a.id
WHERE i.IndexId >= @PageLowerBound AND i.IndexId <= @PageUpperBound
ORDER BY itemdate DESC, id DESC
-- Return the number of pages
SELECT @TotalRecords = COUNT(*)
FROM #ItemIndex
RETURN CEILING(@TotalRecords/@pageSize)
lexy
Participant
1668 Points
441 Posts
Stale Cookie?
May 12, 2006 03:09 PM|LINK
Remember me next time
Isn't this something of a bug?
Doesn't seem to remember much.
Lex
DudeBori82
Member
17 Points
10 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jun 15, 2006 08:15 PM|LINK
In the C# version of the Club Site when a user clicks "Add Event" will be directed to the add event page. If the user does not enter a description for the event, there's no validation for that field and it throws an error reporting a invalid conversion attempt from a DBNull. I haven't found a permanent fix for this because I'm not familiar with the "FormView" control that contains it. A quick fix was that on page load, if the user is adding a new event, I set the text property of the description text boxt to " " so that it is not null. If anyone knows a permafix for this, let me know.
Limmer
Member
40 Points
11 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jun 19, 2006 06:58 PM|LINK
Hi DudeBori82,
I have implemented RequiredFieldValidator fields for all the things that I think are necessay in the database. You can also check each table via the Server Explorer so you know which fields are not allowed to be Null/Nothing.
Limmer
MrLunch
Member
727 Points
144 Posts
Delete location breaks edit event if linked
Jun 21, 2006 12:54 AM|LINK
If you delete a location, and an event exists that uses that location, you cannot then edit the event.
Quick, dirty fix, in locations_edit.aspx, find the delete command in the datasource and change it from
DeleteCommand
="delete from locations where id=@id"to
DeleteCommand
="delete from locations where id=@id;update events set location = NULL where location = @id"Forums Starter Kit
junck
Member
60 Points
12 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jun 26, 2006 12:03 AM|LINK
I found a bug in the events_list.aspx page.
I apologize if this bug has already been covered. I looked through the posts and could not find any threads about it so I decided to post what I discovered. Hope this helps.
To simulate:
1. log in as admin
2. navigate to events_list
3. click "List View"
4. click the green rollover button "Remove"
5. you are redirected to Events_Edit.aspx
6. The event is not removed.
Fix:
Under Begin News Item comment, under <asp:repeater...>, within <ItemTemplate>, and within <asp:panel ID=panel2...>, the line
"<Club:RolloverLink ID="RemoveBtn" runat="server" Text="Remove" NavigateURL='<%# "Events_Edit.aspx?Action=Remove&id=" & cstr(Eval("id")) %>'/>"
should be changed to read
<Club:RolloverLink ID="RemoveBtn" runat="server" Text="Remove" NavigateURL='<%# "Events_Edit.aspx?Action=delete&id=" & cstr(Eval("id")) %>'/>
This fix passes the correct parameter value to "action" that is defined in the events_edit.aspx. Until this fix, the logic in the events_edit.aspx page would fall through to the "Case Else" and land you at the event_edit instead of "removing" the event and redirecting you back to events_list.aspx.
Below is the sub that the "action" value is passed to:
Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)If Not IsPostBack Then
'Initialize the fields
Dim action As Object = Request.QueryString("Action")
If Not action Is Nothing Then
Select Case LCase(CStr(action))
case "new"
'We are in new mode
FormView1.ChangeMode(FormViewMode.Insert)
Dim lp As LocationsPicker = CType(FormView1.FindControl("LocationPicker1"), LocationsPicker)
lp.LocationID = Nothing
Dim dp As DurationPicker = CType(FormView1.FindControl("dtpicker"), DurationPicker)
dp.startDateTime = Now
dp.endDateTime = Now.AddHours(3)
Dim slp As TextBox = CType(FormView1.FindControl("staticURLTextBox"), TextBox)
slp.Enabled = False
Case "delete"
SqlDataSource1.Delete() /* This was origionally "Remove" and I changed to "Delete"
Response.Redirect("Events_list.aspx")
Case Else
'We are in edit mode
Dim cb As CheckBox = CType(FormView1.FindControl("CheckBox1"), CheckBox)
Dim surl As TextBox = CType(FormView1.FindControl("staticURLTextBox"), TextBox)
If Not surl.Text Is Nothing AndAlso surl.Text <> "" Then
cb.Checked = True
surl.Enabled = True
Else
surl.Enabled = False
End If
End Select
End If
End If
End Sub
All human actions have one or more of these seven causes: chance, nature, compulsion, habit, reason, passion, and desire.
Aristotle Greek critic, philosopher, physicist(384 BC - 322 BC)
lexy
Participant
1668 Points
441 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 02, 2006 03:32 PM|LINK
Hi,
This is copied from an old post:
I believe this is not solved yet:
I have the site up-and running, but when I try to add a News entry, and select a future date for the control that says ' The news article will not be visible to users until after this date.', this date doesn't seem to be respected. If I add a news article to be displayed in the future, it still shows ALL the entries from both the home page as well as the news link.
Anyone else have this problem?
Lex
MrLunch
Member
727 Points
144 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 02, 2006 10:17 PM|LINK
Another Club Kit surprise.
In this case, it's the select statement in the sqldatasource on default.aspx, and the stored procedure PagedAnnouncementList, neither one does what the UI suggests it will do.
To fix, in both places, add 'itemdate <= getdate()' to the where clause, i.e.:
Forums Starter Kit
lexy
Participant
1668 Points
441 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 03, 2006 12:56 PM|LINK
Mark,
Once again I thank you.
Man you are invaluable for this Forum.
Truly awesome,
Lex
rhhanson63
Member
354 Points
76 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 03:07 PM|LINK
Would this be the correct syntax on the stored procedure?
SELECT
id, itemdate, title, description, photo FROM Announcements WHERE ((itemdate <= getdate())AND(itemdate > @keydate OR(itemdate = @keydate)
AND (id > @keyid)) ORDER BY itemdate ASC, id ASCBob
MrLunch
Member
727 Points
144 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 05:29 PM|LINK
There was some other problem with that sproc, I forget what exactly, so I had written a slightly different version of it:
ALTER PROCEDURE [dbo].[PagedAnnouncementList] ( @pageNum INT = 1, @PageSize INT = 10 ) AS -- Set the page bounds DECLARE @PageLowerBound int DECLARE @PageUpperBound int DECLARE @TotalRecords float SET @PageLowerBound = @PageSize * (@pageNum - 1) SET @PageUpperBound = @PageSize - 1 + @PageLowerBound -- Create a temp table to put items in the order we want CREATE TABLE #ItemIndex ( IndexId int IDENTITY (0, 1) NOT NULL, NewsId int ) -- Insert into temp table INSERT INTO #ItemIndex (NewsId) SELECT a.id FROM announcements a WHERE itemdate <= GETDATE() ORDER BY itemdate DESC, id DESC -- Get the page we need from the ordered temp table SELECT a.id, a.itemdate, a.title, a.description, a.photo FROM Announcements a JOIN #ItemIndex i ON i.NewsId = a.id WHERE i.IndexId >= @PageLowerBound AND i.IndexId <= @PageUpperBound ORDER BY itemdate DESC, id DESC -- Return the number of pages SELECT @TotalRecords = COUNT(*) FROM #ItemIndex RETURN CEILING(@TotalRecords/@pageSize)Forums Starter Kit