Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Gridview PostBack Problems

Reply
Thread Tools

Gridview PostBack Problems

 
 
barrettenda@gmail.com
Guest
Posts: n/a
 
      03-30-2006
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[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.

 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-30-2006
If you are talking of a master detail design like the first example on
http://www.asp.net/QuickStart/aspnet...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

 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-30-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
Custom GridView Control – Postback Problems Amadeus Consulting ASP .Net Web Controls 3 12-19-2005 03:50 PM
Gridview inside Gridview little problems... Carlos Albert ASP .Net 1 12-06-2005 05:31 PM
Postback not being set to True on first postback =?Utf-8?B?Q2hhZA==?= ASP .Net 2 04-04-2005 06:17 PM
effecting postback without auto postback controls Psych971 ASP .Net 5 12-17-2004 08:53 PM



Advertisments