|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Gridview PostBack ProblemsWhen 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[i]; 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. 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 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.
Problem with User Control and unset references to controls within
row count in inherited GridView control GridView - can't reference value of a non-visible cell?? Use windows control in asp.net 2.0 Re: How to get underlying data of TreeView control? (ASP.NET 2.0) Dynamically created (and selected) radiobuttons fire CheckedChanged event on Postback error in adding user controls at runtime Panel with Header Design Time Error: Error Rendering Control ValidateEvent bug with table and radio button |
|||||||||||||||||||||||