Results 1 to 4 of 4

Thread: [2005] Problems with Gridview and Postback

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    14

    Exclamation [2005] Problems with Gridview and Postback

    hello everyone!

    this is my first post

    Inside the gridview (see the pic), there are two type of rows

    1.- green -> rows obtained by db
    2.- red -> rows obtained by rowdatabound event



    The problem happen when I click the continuar button... I want to obtain the values in the checkbox and textbox fields, but i can't. Apparently the postback event, not triggers the rowdatabound event (in fact there only show two first green marked rows, just in the position there begins rowdatabound event)

    Somebody can help me??
    thx for the help!!!!

    (sorry for my english!)

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Problems with Gridview and Postback

    Has EnableViewState been set to true for the GridView? What might be happening (cannot be sure without looking at code) is that you are not rebinding on postback and so the dynamically created rows are being lost somehow. However, if they are dynamically created, they should be recreated in the Init event before each page load, so that when the button click event (continuar) is finally raised, all the control values are available to you.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    14

    Re: [2005] Problems with Gridview and Postback

    Thank's for your reply...

    Has EnableViewState been set to true for the GridView? -> Yes

    I'll have a solution, I call the checkbox and textbox fields with:

    HTML Code:
    Dim Keys() As String
    Dim FormElements As NameValueCollection
    Dim Counter1 As Integer
    
    FormElements = Request.Form
    Keys = FormElements.AllKeys
    
    For Counter1 = 0 To Keys.GetUpperBound(0)
         If Keys(Counter1).IndexOf("check") <> -1 Then
                        'find a checkbox
         End If
    
         If Keys(Counter1).IndexOf("textbox") <> -1 Then
                        'find a textbox
         End If
    Next
    thanks!!

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Problems with Gridview and Postback

    That'd be another way to do it I suppose, but if you keep working with dynamic controls, you'll need to keep the recreation of controls in mind as it can be cumbersome to have to do this 'manually' each time.

Posting Permissions

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



Click Here to Expand Forum to Full Width