开发者

Is it Advisable to store Gridview search results in Session?

Good Morning,

I have created an ASP.NET 3.5 webform that allows users to search a parts list. The two textbox controls supply the input paramenters to the stored procedure. The gridview returns the search results from the stored procedure.

I have enhanced the gridview to include a template field with a textbox for Quantity, as well as a button control in the gridview footer to be used to Add the Parts (with quantity) to a quote request.

A user might search for a nail and a hammer, select a nail and input 25 quantity and select a hammer with 1 quantity. These items and quantities must be retained for use in the quote process.

Question: Given my scenario, do you advise storing the gridview quantities, part name etc. in a session? If not, what is the best way to save these items for use later in the quote process开发者_JAVA技巧?

Thanks, Sid


While the gridview is being displayed, i.e. you are rendering it, I would keep the details on that page. When you step off that page to continue the ordering process then I would probably store them in the session, or keep them on the page in a hidden area.

The reason for this is that the Session is loaded on every page request so you don't want to keep information in the Session for the shortest amount of time necessary.

To further complicate your application if the user uses the browser back and forward buttons then what would be the expected result. Consider, they have added the nails, and then the hammer, then they click the back button to prior to them adding the ammer, and then add a screwdriver. What is the order? nails, hammer and screwdriver? or nails and screwdriver? Thus keeping the data on the page if possible is good because if the user steps back, so does the order state. Becareful though, you don't want to add so much to the page that the ViewState expands too much, so watch for that and turn it off if you don't need it.


I see no issue with using session as this doesn't sound like a heavy duty app. The only other thing you could do is use a database and store it as a temp row in the database. You'll have to get rid of it when you don't need it.

The only other thing you could do is cache it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜