Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6642407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:55:36+00:00 2026-05-25T23:55:36+00:00

I have a GridView with some BoundFields and two TemplateFields . In these two

  • 0

I have a GridView with some BoundFields and two TemplateFields. In these two TemplateFields, I dynamically create UserControls containing a DropDownList and a TextBox, which users can modify.

When I try to get the values of the controls after a PostBack, the values in BoundFields are still there but my dynamic controls disappears. I can create them again but it won’t get the user’s values… How can I get these values before they’re lost?

Here’s some of my code:

In the RowDataBound event:

Select Case type
    Case "BooleanBis"
        e.Row.Cells(2).Controls.Clear()
        Dim list1 As BooleanBisList = New BooleanBisList(avant, False)
        e.Row.Cells(2).Controls.Add(list1)

        e.Row.Cells(4).Controls.Clear()
        Dim list2 As BooleanBisList = New BooleanBisList(apres, True)
        e.Row.Cells(4).Controls.Add(list2)
    Case "Boolean"
        e.Row.Cells(2).Controls.Clear()
        Dim list3 As BooleanList = New BooleanList(avant, False)
        e.Row.Cells(2).Controls.Add(list3)

        e.Row.Cells(4).Controls.Clear()
        Dim list4 As BooleanList = New BooleanList(apres, True)
        e.Row.Cells(4).Controls.Add(list4)
End Select

In my button click event, I try to get the user control :

Case "String"
    temp.ChampValeurApres = DirectCast(Tableau1.Rows(i).Cells(selectedColumn).Controls(1), TextBox).Text

but i get the error that it doesn’t exist.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:55:37+00:00Added an answer on May 25, 2026 at 11:55 pm

    You should create dynamic controls in RowCreated instead of RowDataBound because this event gets fired on every postback whereas RowDataBound only will fire when the GridView gets databound to it’s DataSource.

    Dynamically created controls must be recreated on every postback with the same ID as before, then they retain their values in the ViewState and events will fire correctly(f.e. a DropDownList’s SelectedIndexChanged event).

    So you should create them in RowCreated and “fill” them in RowDataBound(f.e. the DropDownList datasource/Items or a TextBox-Text).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView control (which renders to table, tr, td) with some BoundFields
I have a GridView which retrieves data from a database. Users have roles, some
Hello I have a gridView which I use to show some pictures on (small
I have a GridView which is showing some data: Entity_ID (PK) Name Description Now
i want to display some information in a listview using the GridView. i have
I have GridView which I can select a row. I then have a button
I have a GridView where one column is bound to an object property containing
I have a GridView populated from an ObjectDataSource with two items in its DataKeyNames
I have bound fields in GridView to some dateTime property of data objects. The
I have a GridView that shows a list of users. Each user has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.