Inserting Records

  • I have a method that populates data in a table. Once the table is populated I dont want to call that populate method again. How to prevent it from being called every time. It is in the Page Load area. Can any one suggest me any thing plz..

    protected void Page_Load(object sender, EventArgs e)

    {

    connectionInfo = ConfigurationManager.ConnectionStrings["Con"].ToString();

    try

    {

    List<video> allVideos = VideoFunctions.GetAllVideos(SortByType.MODIFIED_DATE,

    SortOrderType.DESC, new List<String> (VideoToRetrieve), true, true);

    if (allVideos.Count > 0)

    {

    PopulateCatTable(allVideos);

    }

    [\code]

  • This is an ASP.NET question, not a SQL Server one. You would be better served posting on an ASP.NET forum.

    I might suggest this one: http://www.aspmessageboard.com/

  • try using the ObservableCollection, check to see if there has been any change in your table, if not; don't call the method.

    if not, maybe use some sort of event to trigger the method call instead.

    http://msdn.microsoft.com/en-us/library/ms668604.aspx

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.

  • Hey Thanx!! I will try ur method and see!

  • 2 quick comments

    1st, the page is reloaded every time that the user posts back to the web server, so if you only want it populated on the original load, check the Page.IsPostBack property to determine if it is an original request or a postback inside the page load event.

    2nd, if you are doing this to populate a table for multiple users / sessions to make use of, then you would want to store it in the Cache Object with an expiration on it so that it is available to multiple pages / users. You can put a SQL condition on the cache, so that it monitors the data to see if there are any changes.

    Now, if you are using .Net 3.5 / 4.0 with LINQ, you could also use Synchronization Services in conjunction with SQL 2008 to monitor the database and ensure that your data table in the app is constantly synchronized with the DB.

    Hope this helps.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply