Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cross page postback problem.

Status
Not open for further replies.

iaresean

Programmer
Mar 24, 2003
570
ZA
Hey all;

I have a gridview which display a list of records. The user can then use the select command to select a record. I would then like to redirect the user to a page which displays the full record details and allows them to edit the record.

However I am having trouble passing the id of the record to the next page. At the moment, when the user clicks the required record an event fires which populates a hidden field (hdnId) with the id of the record, and then it does a server.transfer to the detail page.

I have set the previouspage directive in the detail page, however, as a postback actually wasn't fired in the list page I am unable to access the value of the hidden field. I have browsed through the functionality of the gridview control and it doesn't seem to have the ability to do crosspageposting or general postbacks.

Can anybody provide me with some advice on how to get around this problem?

Any and all help is greatly appreciated.

Sean. [peace]
 
Sean, question. Why not make the Grid "editible" and do your edits in place? Just a thought. You might consider transfering your params via a QueryString (see faq855-4372) in stead of a server.transfer - but I have not used at all the server.transfer method so you might have an advantage here I am unaware of. Look forward to seeing the solution you decide to go with.
 
As Isadore has said you can use a query string. Also you can use a session variable. More importantly, Isadore's suggestion about using the grids built in edit properties would be the best was to go, and the least amount of coding. Alternatively, what I have done on some pages, is to have the user click a row, as you are doing, and then populating, dropdowns, textboxes, etc, where they can then edit and save.
It seems you are using ASP.NET 2.0, correct? If so the best way to go is to have a gridview that shows the master records, and a detailsview that that gets populated once the user clicks a row in the gridview. 2.0 really lends itself to master/detail pages.


Jim
 
Thanks all;

I do have grid editing available at the moment, however there are a large amount of other fields that go with these records and I only have a fixed amount of space to work with in my gridview. Also I don't find it visually appealling to have large amounts of columns in the gridview, I personally prefer only displaying the most important ones with an option to select a record to view a full details page.

Thanks for the URL parameter recommendation, I have in fact gone on with that solution. Although I have never been a fan of passing variables using the URL string - I was hoping that cross page postback would be a nice alternative. :-/ Also I don't want to use Sessions as it means extra maintenance for me to ensure I don't unneccessary use and waste server memory.

RTomes, thanks for the link, I will have a look and see if I can apply what they teach to my solution.

Once again, thanks for all the responses guys!

Sean. [peace]
 
Sean - you might rethink the QueryString approach, I am a big fan of it. I have some pages that pass up to 30 variables -- and never a complaint from the 600+ users of the site. Also, they are sitting there for the duration and easily retrieved, no matter what the client is up to (of course transferring them to a hidden field, etc is just as good - problem is, when you click on the Grid, you'll have to transfer the parameters elsewhere to process so in the end the QS is pretty attractive; albeit public.

Let us know how RTomes suggestion turns out Sean, interesting to see if you can get it to work with a Grid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top