views:

116

answers:

2

Hi I have an objectDataSource and i am trying to pass an object as parameter in its Inserting event. For some reason the "Inserting" is not getting fired up before Insert is called.

It is not getting into

ObjectDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e)

Event block for some reason. Any idea ?

Here is the ObjectDataSource and the code where its Insert method is been called.

alt text

here is the object i need to pass

  public class FeedItem
    {
        string feedItemTitle;
        string feedItemLink;

        public string FeedItemTitle
        {
            get { return feedItemTitle; }
        }
        public string FeeDItemLink
        {
            get { return feedItemLink; }            
        }

        public FeedItem(string _feedItemTitle, string _feedItemLink)
        {
            feedItemTitle = _feedItemTitle;
            feedItemLink = _feedItemLink;
        }
    }

Thanks

A: 

To pass user-defined objects to a ObjectDataSource you must including a default constructor that takes no parameters. The data source object's public properties must also expose both get and set accessors.

 public class FeedItem
 {
    string feedItemTitle;
    string feedItemLink;

    public string FeedItemTitle
    {
        get { return feedItemTitle; }
        set { feedItemTitle= value; }
    }

    public string FeeDItemLink
    {
        get { return feedItemLink; }
        set { feedItemLink= value; }            
    }

    public FeedItem(){}

    public FeedItem(string _feedItemTitle, string _feedItemLink)
    {
        feedItemTitle = _feedItemTitle;
        feedItemLink = _feedItemLink;
    }
 }
Phaedrus
Thanks mate, have replaced my class body with your's but problem is still there. for some reason control is not jumping into the event block...
Asad Butt
As you may see, breakpoint is set, but nothing happens while debugging but the exception is raised
Asad Butt
+1  A: 

Once i encountered the same issue but solution was very simple, one of our developer has subscribed the event in if (Page.PostBack == false)

So as per the fundamentals (http protocol) server will forget binding on next post back

Harryboy