Problem with Gridview and Postback

  • Thread starter Thread starter anr
  • Start date Start date
A

anr

Hi,

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

http://img233.imageshack.us/img233/3528/lalaqg4.jpg

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!)
 
It sounds to me like you need to debug through your code and watch what
happens. What I predict is you are binding the page in the Page_Load (or
similar) and thus rebinding before you start looking for rows. If so, you
need to adjust the pattern so the bind is in a separate event and only
called once for the original page

if(!Page.IsPostBack)
{
//call bind routine
}

You can then rebind from event handlers, if necessary, by calling the bind
event again. But, you can also look for values in any of the rows without
the danger of rebinding (unless your button is a standard HTML button that
acts as a link? - long story ... ignore that ;->).

If none of this helps, post the code for the page and someone should be able
to show you where you have coded the order incorrectly.

I could be wrong, but this is my first guess based on your query.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
hi, thanks for your reply...

after the button "continuar" is pressed, i call a sub where
i put this:

sqldatasource2.selectcommand = "select * from table"
gridview2.databind()

and it's reloads the gridview but without textbox and
checkbox values!...

and if i try to access to these values in this routine, i
only obtained the six rows from bd.

for each row2 in gridview2.rows
response.write (row2.cells(8).text.tostring)
next

8 is the index of the cell that i want to response any
checkbox, but i can't
 
You do not have to rebind if you simply want what you have already painted.
It will pull from viewsource and add anything the user has changed. If you
rebind, you will have to marry the binding with anything the user has
selected.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
ok, i understand...

but if i press "continuar" button, it seems that not load
the rowdatabound event, it's any chance to load this event
in command line?

for ex, gridview2_rowdatabound(sender, e)

etc

thx!
 
Back
Top