dynamic controls not updated

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default dynamic controls not updated

    Hi Everyone

    I have a web application and all it basically does is ask for a user
    id and show a questionnaire. To create the questionnaire, I get the
    list of questions from the database and dynamically add controls
    (i.e,. labels, radiobuttons, textboxes) for each question. If the user
    has visited the page before, I will go to the database and populate
    the questionnaire with the answers that the user have entered before
    and display it to the user and allow them to edit it.

    Everytime the page loads, I will recreate the dynamic controls and
    populate it with that user's information from the database. However
    my problem is that even if there is a different user id entered, the
    values for the dynamic controls stay the same even though I just
    recreated them! So if I put in User1 for the user id, a questionnaire
    will show up with User1's information from the database, but if I put
    in User2 next for the user id, I get a questionnaire with User1's
    information on it. Does anyone know why the values for the
    dynamically created controls are not being updated?

    I heard that it might help to set enableviewstate to false, but I
    can't do that because I use request.form to get the values from those
    dynamically created controls. Thanks in advance.

    Kelly
    Kelly Guest

  2. Similar Questions and Discussions

    1. Dynamic Controls
      hi, Here's what I'm trying to do. A simple datagrid that is populated by a variable amount of data, which displays a different amount of rows. ...
    2. dynamic controls in asp.net....Please Help...
      Hello People, I would appreciate your responses on this. I am writing an asp.net web-application involving C#. I am actually building a test...
    3. Dynamic Controls - Still!
      Hi Jim Thanks for your help. I changed the table from an ASP.Net table to an HTML table. I am till having the problem of the control placed...
    4. Datagrid not updated during delete, but updated during insert and update
      Hello everyone. A test webform here, single datagrid bound to one table through dataset, and controls to delete, update and insert data. The code...
    5. please help with dynamic user controls
      Hi Suzanne I agree. If you ever want to add controls dynamically to a page and have them track their viewstate, you need to create them during...
  3. #2

    Default Re: dynamic controls not updated

    Hi,

    is it possible that any caching is happaned ?

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: dynamic controls not updated

    try to set Response.Expires = -1. this will prevent your browser to get
    a page from the cache.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  5. #4

    Default Re: dynamic controls not updated



    That didn't work.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kelly Lim Guest

  6. #5

    Default Re: dynamic controls not updated

    Let’s check it on simple project with one page and 2 dynamic controls.
    Don’t copy from your existing project create new. It is still happening?
    If so send the project source. if the new project works OK it might be
    something in your code logic.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  7. #6

    Default Re: dynamic controls not updated

    Here is my code (After postback, I dynamically recreate the controls but
    with some changes but the changes aren't reflected:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    Dim Radio1 As RadioButton
    Dim Radio2 As RadioButton
    Dim TextBox1 As TextBox

    If Not Me.IsPostBack Then
    TextBox1 = New TextBox()
    TextBox1.ID = "myTestBox1"
    TextBox1.Text = "Before postback"

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(TextBox1)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    Radio1 = New RadioButton()
    Radio1.ID = "myRadio1"
    Radio1.Text = "Red"
    Radio1.GroupName = "Color"
    Radio1.Checked = False

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(Radio1)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    Radio2 = New RadioButton()
    Radio2.ID = "myRadio2"
    Radio2.Text = "Blue"
    Radio2.GroupName = "Color"
    Radio2.Checked = False

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(Radio2)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    Else

    TextBox1 = New TextBox()
    TextBox1.ID = "myTestBox1"
    TextBox1.Text = "After postback"

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(TextBox1)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    Radio1 = New RadioButton()
    Radio1.ID = "myRadio1"
    Radio1.Text = "Red"
    Radio1.GroupName = "Color"
    Radio1.Checked = True

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(Radio1)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    Radio2 = New RadioButton()
    Radio2.ID = "myRadio2"
    Radio2.Text = "Blue"
    Radio2.GroupName = "Color"
    Radio2.Checked = True

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(Radio2)

    Me.FindControl("Form1").FindControl("plhTest").Con trols.Add(New
    LiteralControl("<br>"))

    End If

    End Sub




    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kelly Lim Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139