Setting Resources When Inserting/Editing

2 posts, 0 answers
  1. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 08 Feb 2010 Link to this post

    I'm using the built-in advanced edit forms created by the Scheduler control. I am using SqlDataSource controls for my resources and for scheduler insert/update/deletes. I have one resource where I would like the user to be able to enter a custom value, while also being able to select from existing items (i.e. The resource is a list of buyers. I want them to be able to enter a new buyer and save the task with the newly created buyer).

    I've made the RadComboBox control for the Buyer list to allow custom text and I handle the AppointmentCommand event checking if an insert/update command was raised and I then check if it's a new buyer and save it. I then add the new buyer to the list and select it.

    Like so:
    Protected Sub rsTasksNew_AppointmentCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentCommandEventArgs) Handles rsTasksNew.AppointmentCommand 
                'check if insert command 
                If e.CommandName = "Insert" Or e.CommandName = "Update" Then 
                    Dim ddlBuyer As RadComboBox = CType(e.Container.FindControl("ResAssigned-To"), RadComboBox) 
                    'check for existing buyer with same name and set them as the selected index 
                    ddlBuyer.SelectedIndex = ddlBuyer.FindItemIndexByText(ddlBuyer.Text.Trim(), True) 
                    'hold buyer id 
                    Dim BuyerId As Integer = IIf(ddlBuyer.SelectedIndex > -1, ddlBuyer.SelectedValue, 0) 
                    'if new buyer being entered 
                    If BuyerId = 0 Then 
                        'save new buyer 
                        BuyerId = SaveBuyer(ddlBuyer.Text.Trim(), Session(SessionVariables.Cur_Client_ID)) 
                        'add buyer to list and set as selected 
                        ddlBuyer.Items.Add(New RadComboBoxItem(ddlBuyer.Text, BuyerId)) 
                        ddlBuyer.SelectedValue = BuyerId 
                    End If 
                End If 
            Catch ex As Exception 
            End Try 
        End Sub 
    This isn't working for some reason. It keeps throwing this error:
    Server Error in '/GoRentPro' Application. 
    Invalid length for a Base-64 char array. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  
    Exception Details: System.FormatException: Invalid length for a Base-64 char array. 
    Source Error:  
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
    Stack Trace:  
    [FormatException: Invalid length for a Base-64 char array.] 
       System.Convert.FromBase64String(String s) +0 
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +72 
       System.Web.UI.LosFormatter.Deserialize(String input) +11 
       Telerik.Web.UI.AdvancedTemplate.ExtractResourceValues(IDictionary target) +598 
       Telerik.Web.UI.AdvancedTemplate.ExtractValues(Control container) +362 
       Telerik.Web.UI.RadScheduler.InsertAppointmentInline() +34 
       Telerik.Web.UI.RadScheduler.OnBubbleEvent(Object source, EventArgs args) +326 
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118 
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135 
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 
    Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 

    If you could tell if this even possible to do or if I'm doing it wrong. I am using the latest version of the controls, 2010.3.1314.

  2. Peter
    Peter avatar
    6637 posts

    Posted 11 Feb 2010 Link to this post

    Hi Robert,

    I recommend you use custom attributes instead of resources for this case. Attached is a demo web site of the needed functionality.

    Best wishes,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top