Gridview PostBack Problems

Discussion in 'ASP .Net Web Controls' started by barrettenda@gmail.com, Mar 30, 2006.

  1. Guest

    When a user selects an item from a dropdown list, the page is posted
    back and the gridviews are binded to contain the new data because a new
    parameter has been specified. But when I manually select a particular
    row and cell using the code


    for (int i = 0; i < GridView1.Rows.Count; i++)
    {

    GridViewRow row = GridView1.Rows;

    temp = row.Cells[5].Text;

    }

    the value of temp is the old value before the page was posted back. I
    am binding the gridview before I run the code above. I am really under
    pressure to have this done for tomorrow. I just can't figure it out.
    , Mar 30, 2006
    #1
    1. Advertising

  2. Guest

    If you are talking of a master detail design like the first example on
    http://www.asp.net/QuickStart/aspnet/doc/data/databases.aspx

    Then try accessing the values within your gridview's databound event
    handler.

    Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles GridView1.DataBound
    For Each row As GridViewRow In GridView1.Rows
    Dim cell1 As String = row.Cells(1).Text
    Dim cell2 As String = row.Cells(2).Text
    Next
    End Sub
    , Mar 30, 2006
    #2
    1. Advertising

  3. Guest

    The master-detail design I was talking about in the above post can be
    described as follows.
    Master data control bound to -> Master data source.
    Details data control bound to -> Details data source.
    Details data source selected data controlled by -> master data source.

    When a new value is selected in the master data control (dropdownlist
    in this case) it changes the select parameter that the details data
    source uses to select data on the next postback.

    On the postback, the details data control (gridview in this case) has
    it's data restored at first to the previous state (old values) - it is
    only after it does a data bind on the details data source before the
    new values is available in the details data control (gridview).

    So if you check gridview's data on the postback during page init or
    load, you will get the old data.
    It's only after the details' DataBound event is raised before the new
    values available.

    Hope that helps.
    , Mar 30, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Psych971
    Replies:
    5
    Views:
    4,594
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    483
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  3. Carlos Albert

    Gridview inside Gridview little problems...

    Carlos Albert, Dec 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,648
    Carlos Albert
    Dec 6, 2005
  4. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,946
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  5. Amadeus Consulting

    Custom GridView Control – Postback Problems

    Amadeus Consulting, Dec 15, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    351
    Amadeus Consulting
    Dec 19, 2005
Loading...

Share This Page