468,738 Members | 1,771 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

Server.Transfer Help

I'm having some problems with using Server.Transfer and I
am hoping somebody can help me.

Page 1 has a datagrid, Page 2 has a form.

If a user goes to page 1 and selects something out of the
datagrid I want to transfer the value of that records item
number in the grid over to page 2. I use the passed
number to retrieve data from a database and populate the
form.

So far, what I've explained I have working. My problem is
that when I go directly to page 2 I get an error about an
invalid cast type and I want to see a blank form that I
can use to insert a new record into the db (as opposed to
updating an existing record when the value gets transfered
to the form).

I am hoping that somebody can explain to me how to do this.

Thanks,
Jeremy

Nov 17 '05 #1
2 1498
e
I'm not really sure how you have this setup, but my initial impression is
that you may want to consider constructing it a little differently. Namely,
use a client-side redirect instead of a server.transfer.

I dunno how you would logistically do this with a datagrid, but I'm assuming
it's possible - on Page 1, when a user clicks a record, instead of
server.transfering to Page 2, perform a client-side redirect to Page 2 and
include the record value in the query string, e.g. redirect to
"page2.aspx?Record=<someVariablevalue>"

Then I would create Page 2 so that it looks for the query string Record
value in it's Page_Load event, and if it finds it, it does it's thing and
populates the form based on the Record value. If it doesn't find the Record
value (or if it's an illegal value), then default to the behavior of
creating a new record.

This would create a structure where Page 2 knows how to behave independantly
of Page 1, and Page 2 could be called from any page that is able to pass it
an appropriate value.

You may be able to do a response.redirect in the datagrid's click event, or
you may have to use a registerOnSubmit on Page 1 to intercept the postback
event... not sure which better ( or works ), if either.

Hope I'm not too off base here trying to help...

"Jeremy" <Jk*******@nohtomailspam.com> wrote in message
news:05****************************@phx.gbl...
I'm having some problems with using Server.Transfer and I
am hoping somebody can help me.

Page 1 has a datagrid, Page 2 has a form.

If a user goes to page 1 and selects something out of the
datagrid I want to transfer the value of that records item
number in the grid over to page 2. I use the passed
number to retrieve data from a database and populate the
form.

So far, what I've explained I have working. My problem is
that when I go directly to page 2 I get an error about an
invalid cast type and I want to see a blank form that I
can use to insert a new record into the db (as opposed to
updating an existing record when the value gets transfered
to the form).

I am hoping that somebody can explain to me how to do this.

Thanks,
Jeremy

Nov 17 '05 #2
Thanks for the reply. That's exactly how I had it before,
however, I kept having problems. Not really sure why, but
when I would click on a link that goes back to the grid
and then select the same item the form would be empty. I
tried making sure the page wasn't cached but that didn't
help.

So what I wanted to do was once the page recognized that a
user wanted to select something from the grid it would set
a public property variable to be the value of the item in
the grid and transfer it's processing over to the form
page. And I would have the form page try to recognize if
the data was being passed and do all the stuff you said.
However, I'm not exactly sure how to do this.

Jeremy
-----Original Message-----
I'm not really sure how you have this setup, but my initial impression isthat you may want to consider constructing it a little differently. Namely,use a client-side redirect instead of a server.transfer.

I dunno how you would logistically do this with a datagrid, but I'm assumingit's possible - on Page 1, when a user clicks a record, instead ofserver.transfering to Page 2, perform a client-side redirect to Page 2 andinclude the record value in the query string, e.g. redirect to"page2.aspx?Record=<someVariablevalue>"

Then I would create Page 2 so that it looks for the query string Recordvalue in it's Page_Load event, and if it finds it, it does it's thing andpopulates the form based on the Record value. If it doesn't find the Recordvalue (or if it's an illegal value), then default to the behavior ofcreating a new record.

This would create a structure where Page 2 knows how to behave independantlyof Page 1, and Page 2 could be called from any page that is able to pass itan appropriate value.

You may be able to do a response.redirect in the datagrid's click event, oryou may have to use a registerOnSubmit on Page 1 to intercept the postbackevent... not sure which better ( or works ), if either.

Hope I'm not too off base here trying to help...

"Jeremy" <Jk*******@nohtomailspam.com> wrote in message
news:05****************************@phx.gbl...
I'm having some problems with using Server.Transfer and I am hoping somebody can help me.

Page 1 has a datagrid, Page 2 has a form.

If a user goes to page 1 and selects something out of the datagrid I want to transfer the value of that records item number in the grid over to page 2. I use the passed
number to retrieve data from a database and populate the
form.

So far, what I've explained I have working. My problem is that when I go directly to page 2 I get an error about an invalid cast type and I want to see a blank form that I
can use to insert a new record into the db (as opposed to updating an existing record when the value gets transfered to the form).

I am hoping that somebody can explain to me how to do this.
Thanks,
Jeremy

.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Justin | last post: by
5 posts views Thread by Nedu N | last post: by
18 posts views Thread by UJ | last post: by
8 posts views Thread by bryan | last post: by
2 posts views Thread by Fabrice | last post: by
6 posts views Thread by n# | last post: by
1 post views Thread by CARIGAR | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.