AutoPostback doesn't occur on insert

Last post 10-11-2006 7:32 PM by pkellner. 3 replies.

Sort Posts:

  • AutoPostback doesn't occur on insert

    10-11-2006, 3:13 PM
    • Loading...
    • bduris
    • Joined on 09-11-2006, 6:07 AM
    • Posts 8

    Hi, I have a DetailsView set to default to insert and a GridView under it to show all the inserted items. They are both connected to the same datasource. When the datasource is empty the first time, the GridView is not visible since there's no data to display. But the problem is when I insert the first record, it inserts it into the database (I can see it from the database), but the GridView is still not visible. It looks like the GridView needs an AutoPostback to kickstart it. How can I make the GridView appear with the new data after the insert.

     Thanks!

  • Re: AutoPostback doesn't occur on insert

    10-11-2006, 4:16 PM
    • Loading...
    • pkellner
    • Joined on 11-12-2004, 5:42 AM
    • San Jose, California
    • Posts 3,370
    • Moderator
      TrustedFriends-MVPs
    after you do the insert, call databind on the DetailsView control
    Peter Kellner
    http://73rdstreet.com and blogging at
    http://PeterKellner.net
    MVP, ASP.NET
  • Re: AutoPostback doesn't occur on insert

    10-11-2006, 7:24 PM
    • Loading...
    • bduris
    • Joined on 09-11-2006, 6:07 AM
    • Posts 8

    I'm still a newbie. Can you generally describe what the databind statement would look like? I assume it would go in the ItemInserted event of the DetailsView control.

  • Re: AutoPostback doesn't occur on insert

    10-11-2006, 7:32 PM
    Answer
    • Loading...
    • pkellner
    • Joined on 11-12-2004, 5:42 AM
    • San Jose, California
    • Posts 3,370
    • Moderator
      TrustedFriends-MVPs

    DetailsView1.DataBind();

     You could put this any place (like at the end of your button script), or like you say in the ItemInserted event will work also
     

    Peter Kellner
    http://73rdstreet.com and blogging at
    http://PeterKellner.net
    MVP, ASP.NET
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter