locked
Error trying to set InputParameters in the code behind. RRS feed

  • Question

  • User-2094329167 posted

    I have an Update method for my ObjectDataSource with the following signature Update(Landmarl oLandmark);

    The object is a little complicated and contains a number of custom objects itself. So I'm handling the ObjectDataSource control's Updating method. However when I try to set the parameter using the following code:

    e.InputParameters.Add("oLandmark",oLandmark);

    The code throws the following exception:

    The OrderedDictionary is readonly and cannot be modified

    Is there anyway to set custom parameter values for an ObjectDataSource control? The .NET documentation suggested setting it in this way, however its not working.

    Friday, July 14, 2006 3:39 PM

All replies

  • User1224304770 posted
    Have you set the DataObjectTypeName property of the ObjectDataSource control? If yes, then you can modify only the data object properties for the items in this dictionary; you cannot add or remove parameters.
    Wednesday, July 19, 2006 4:04 AM
  • User1778685159 posted

    Hello Shaggiddi,

     I am not sure if you have solved your problem by now or not. But I was having a similar problem, and the way I solved it was by using:

    1    ObjectDataSource1.SelectParameters["ParameterName"].DefaultValue = "value to set";
    2    
    

     I hope this helps. [:)]

     

    Friday, March 23, 2007 12:18 AM
  • User75623505 posted

    Try doing this for custom objects in the ObjectDataSource1_Updating(object sender, ObjectDataSourceMethodEventArgs e) event. This works:

    NewsDTO newsDTO = (NewsDTO)e.InputParameters["newsDTO"];

    newsDTO.NewsID = Convert.ToInt32(Request.QueryString["id"]);

    newsDTO.NewsHeadline = headlines;

    newsDTO.NewsDate = newsDate;

    newsDTO.NewsDetail = editednews;

    Friday, July 27, 2007 5:42 AM
  • User-367511527 posted

     Ok this actually worked for me but I don't understand how?

    Can you explain me how is it that altering a separate instance of an object changes the values of the e.InputParameter(0)? Is this some built in behavior of objectdataSource's Updating event?

    Thursday, January 13, 2011 9:30 AM