1 Replies - 768 Views - Last Post: 28 November 2012 - 10:30 PM Rate Topic: -----

#1 robgw3  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 138
  • Joined: 23-February 12

How to update Listview server control when database is changed?

Posted 28 November 2012 - 07:35 PM

I have a listview server control that i want to have populated with values from a database, i already have it databound to the database but i want to make it update when i add or remove something from the database.

This is the code for my listview control

<asp:AccessDataSource id="photoSource" Runat="Server"
                    DataFile="~/App_Data/photos.accdb"
                    SelectCommand="SELECT DISTINCT source FROM photos ORDER BY source"/>
                <asp:ListBox ID="lstUploaded" DataSourceID="photoSource" DataTextField="source" DataValueField="source" runat="server" />


Does that not update on postback at all? The item is being deleted from the database so i know it's not just keeping that.

Is This A Good Question/Topic? 0
  • +

Replies To: How to update Listview server control when database is changed?

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: How to update Listview server control when database is changed?

Posted 28 November 2012 - 10:30 PM

How are you adding and removing the data from the database? The ListBox does not automatically monitor the state of the data in the database. During whatever event is being used to add/remove the data you'll also need to call the databind method of the listbox.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1