Quick Nav:  Online Store   |   Login | Register

unable to update or insert - User Defined Tables

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
brandon arnold
<20 Posts
Posts:2


12/15/2003 7:22 AM  
when using the DesktopDefault.aspx and EditModule.aspx files that came with CSS, none of my updates and inserts for User Defined Tables work. If I replace them with the original files (ones that came with DotNetNuke) everything works fine. Of course, then I do not have the skin... Anyone else having these troubles?
John Mitchell
<500Posts
Posts:355


12/15/2003 8:52 PM  
The problem is because of how the user defined table module picks up the field values from the postback. The skins version places the original control inside another one which makes it's client id a little different ( It's a .Net thing). If you will replace the update_click function in EditUserDefinedTable.ascx.vb with this code and recompile you'll be back up and running.

Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click 

Dim objUserDefinedTable As New UserDefinedTableDB() 
Dim ValidInput As Boolean = True 
Dim strMessage As String 
Dim strFieldValue As String = "" 

Dim dr As SqlDataReader = objUserDefinedTable.GetUserDefinedFields(ModuleId) 
While dr.Read 
strFieldValue = Request.Form("_ctl0:_ctl0:" & dr("FieldTitle")) 
If strFieldValue <> "" Then 
Select Case dr("FieldType").ToString 
Case "Int32" 
If ValidateNumeric(strFieldValue, "0123456789+-") = False Then 
strMessage += "
" & dr("FieldTitle").ToString & " Must Contain A Valid Integer Value" 
ValidInput = False 
End If 
Case "Decimal" 
If ValidateNumeric(strFieldValue, "0123456789+-.") = False Then 
strMessage += "
" & dr("FieldTitle").ToString & " Must Contain A Valid Decimal Value" 
ValidInput = False 
End If 
Case "DateTime" 
If IsDate(strFieldValue) = False Then 
strMessage += "
" & dr("FieldTitle").ToString & " Must Contain A Valid Date Value" 
ValidInput = False 
End If 
Case "Boolean" 
Select Case LCase(strFieldValue) 
Case "true", "false" 
Case Else 
strMessage += "
" & dr("FieldTitle").ToString & " Must Contain A True/False Value" 
ValidInput = False 
End Select 
End Select 
End If 
End While 
dr.Close() 

If ValidInput Then 
If UserDefinedRowId = -1 Then 
UserDefinedRowId = objUserDefinedTable.AddUserDefinedRow(ModuleId, UserDefinedRowId) 
End If 

dr = objUserDefinedTable.GetUserDefinedFields(ModuleId) 
While dr.Read 
strFieldValue = Request.Form("_ctl0:_ctl0:" & dr("FieldTitle")) 
objUserDefinedTable.UpdateUserDefinedData(UserDefinedRowId, dr("UserDefinedFieldId"), strFieldValue) 
End While 
dr.Close() 

objUserDefinedTable.UpdateUserDefinedRow(UserDefinedRowId) 

Response.Redirect(ViewState("UrlReferrer"), True) 
Else 
lblMessage.Text = strMessage 
End If 

End Sub 
brandon arnold
<20 Posts
Posts:2


12/18/2003 4:07 PM  
Looks like that worked! Thanks a lot!
John Mitchell
<500Posts
Posts:355


12/18/2003 11:01 PM  
No problem. You could also compile that whole class into a seperate namespace & dll if you want to keep your stuff working when upgrades to DNN are made available.
John Mitchell
<500Posts
Posts:355


12/18/2003 11:05 PM  
By the way, I just realized there was a bug in the post above that only allowed the updates from the first field value to get populated into all fields. In the second loop you need to add the assignment of the field value from the form again.
strFieldValue = Request.Form("_ctl0:_ctl0:" & dr("FieldTitle")) 
The code in the post above has been edited to reflect this.
Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
Forums >Snapsis Product Support >Bugs and other Issues > unable to update or insert - User Defined Tables



ActiveForums 3.7
Powered by: Snapsis Software