Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Tracking data change - ViewState??

Tracking data change - ViewState??

Scheduled Pinned Locked Moved ASP.NET
questioncsharpcsshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ShakeelN
    wrote on last edited by
    #1

    Hi, I'm fairly new to .NET and I have a problem that I've been trying to resolve for days now and haven't been able to find a solution. Briefly, I have a web page with a number of dropdownlist and textbox controls and a datagrid at the bottom of the page which I want to use to record the history. The idea is that a user enters data and then hits the "save" button on the page. At each save I create a new row on the grid. What I want to do is find out which field(s) have changed since the page was loaded or since the last save and record those field names in the history. I've read a lot about ViewState. I thought that if the page and controls have the EnableViewState property enabled then ViewState should automatically track the state of these controls. I assumed then that in my save routine, I could uses something like ViewState.IsItemDirty(myControlName) to find out if a certain field has changed, since the last save/page load. But I can't get this to work!!! ViewState.Count is 0! Do I have to add records to ViewState manually and then during Save, compare each field value with the value stored in ViewState to see if it has changed? If so then what is the purpose of the EnableViewState property. Is there a more elegant way of doing this? Shakeel

    P 1 Reply Last reply
    0
    • S ShakeelN

      Hi, I'm fairly new to .NET and I have a problem that I've been trying to resolve for days now and haven't been able to find a solution. Briefly, I have a web page with a number of dropdownlist and textbox controls and a datagrid at the bottom of the page which I want to use to record the history. The idea is that a user enters data and then hits the "save" button on the page. At each save I create a new row on the grid. What I want to do is find out which field(s) have changed since the page was loaded or since the last save and record those field names in the history. I've read a lot about ViewState. I thought that if the page and controls have the EnableViewState property enabled then ViewState should automatically track the state of these controls. I assumed then that in my save routine, I could uses something like ViewState.IsItemDirty(myControlName) to find out if a certain field has changed, since the last save/page load. But I can't get this to work!!! ViewState.Count is 0! Do I have to add records to ViewState manually and then during Save, compare each field value with the value stored in ViewState to see if it has changed? If so then what is the purpose of the EnableViewState property. Is there a more elegant way of doing this? Shakeel

      P Offline
      P Offline
      Plunging_Falcon
      wrote on last edited by
      #2

      You don't need to use ViewState for just static controls on the page. ASP.NET does all the work for you. If you have a textbox on the page and you need to find out if the text changed that's what the TextChanged event is for. You need to write a handler for that event. Same for dropdownlists: SelectedIndexChanged event.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups