Insert New record not refreshing dropdown list

Last post 03-27-2008 1:10 PM by lahorya. 9 replies.

Sort Posts:

  • Insert New record not refreshing dropdown list

    03-27-2008, 10:40 AM
    • Loading...
    • riprod
    • Joined on 02-09-2008, 12:04 AM
    • Posts 90

    I have a simple dropdown list of records in my database, that links to a details view, where I can edit, delete or add a new record.

    If I add a new record, it works fine but the dropdown does not refresh, even if I click refresh. I have to logout and quit my browser and launch it again to see the new records in the drop down.

    Any ideas how to make it refresh automatically ?

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 10:41 AM
    Answer
    • Loading...
    • pkellner
    • Joined on 11-12-2004, 10:42 AM
    • San Jose, California
    • Posts 3,242
    • Moderator
      TrustedFriends-MVPs

    you should probably ask the list to get it's data again.

     

    DropDownList1.DataBind()

     

    Peter Kellner
    http://73rdstreet.com and blogging at
    http://PeterKellner.net
    MVP, ASP.NET
  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 10:57 AM
    • Loading...
    • riprod
    • Joined on 02-09-2008, 12:04 AM
    • Posts 90

    Could you elaborate, I'ma  real newbee to .Net

     Where do I put the 'DropDownList1.DataBind()' ?

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 11:01 AM
    • Loading...
    • lahorya
    • Joined on 03-31-2007, 5:11 PM
    • Posts 168

    you need to write this code DropDownList1.DataBind() in side RowCreated or RowDeleted or RowUpdated events of your details view depends what r u tring to do. hope this helps.

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 11:10 AM
    • Loading...
    • riprod
    • Joined on 02-09-2008, 12:04 AM
    • Posts 90

    nope, sorry.... complete newbee here.

    Where do I even find the RowCreated, RowDeleted and RowUpdated events. It's not in the code behind ? Nothing by those names.
    Could you give me a clip a code that I should be looking for ?

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 11:35 AM
    Answer
    • Loading...
    • lahorya
    • Joined on 03-31-2007, 5:11 PM
    • Posts 168

     if you select your details view or gridview whatever you are using and go to properties window where you will see an event button, click on the button it will show you the all event of the selected control.  then just double click on the event you want.  by double clicking on the event it will crate the event and take you to the event in the code behind.  hope this helps.

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 11:48 AM
    • Loading...
    • riprod
    • Joined on 02-09-2008, 12:04 AM
    • Posts 90

    Yes, thank you!

    Working perfect now

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 11:53 AM
    • Loading...
    • lahorya
    • Joined on 03-31-2007, 5:11 PM
    • Posts 168

     dont forget to make it Answer if it helps you.  can you click on the answer button please.

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 12:08 PM
    • Loading...
    • riprod
    • Joined on 02-09-2008, 12:04 AM
    • Posts 90

    just one more questions.

    How would I use the Inseerting handler to insert a static value into the database. Basically I am trying to insert the current date into the database field dateregistered. I tried the follow but it doesn't work.

    Protected Sub ObjectDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles ObjectDataSource1.Inserting
    e.Value(
    "dateregistered") = Now()
    End Sub

     

  • Re: Insert New record not refreshing dropdown list

    03-27-2008, 1:10 PM
    • Loading...
    • lahorya
    • Joined on 03-31-2007, 5:11 PM
    • Posts 168

     try

        e.Value("dateregistered") = DateTime.Now
     

Page 1 of 1 (10 items)