James

James

  • NA
  • 6
  • 0

DetailsView returns null values on postback???

Oct 26 2009 4:42 PM
Hi,

I want to use a DetailsView to insert a record into an empty list.
I have a DetailsView in my page source (DefaultMode set to insert), and the datasource in set in the codebehind.


     myObject = new CustomObject();

     if (!IsPostBack)
     {
        myDetailsView.DataSource = new List<CustomObject>() {myObject};
        myDetailsView.DataBind();
     }

...Then I run the website and type some text into one of the bound fields,
then click a button on the form...


     protected void Button_Click(object sender, EventArgs e)
     {
        string s = myObject.myProperty;
     }


But the value of the object is NULL.
Even myDetailsView.DataSource returns an empty list

what am I doing wrong??? I just want to retrieve the values types into the DetailsView
Thanks

James


Answers (5)