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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to code a lookup control in ASP.NET 1

Status
Not open for further replies.

ASPNeophyte

IS-IT--Management
Jan 1, 2009
2
CA
I'm building a web order entry form for an ERP application. The application could (potentially) have 1000's of items, and I'm trying to create a reasonable lookup control. When a user clicks on a lookup button on the order entry page, it should pop up a window (or a modalpopup, I don't care), which shows them a gridview filled with items from the database. They should be able to search through the gridview, and upon SELECTing an item, the screen should close, and the item number should be "written" back into the "item number" field on the parent form.

This would be unbelievably easy in vb.net, but I've been ripping my hair out for days in ASP.NET. I've been trying to work with a ModalPopupExtender to get it done, but at this point I'd just kill for an example of any sort. Can somebody help me out?
 
What if you have the grid on the main form and make it invisible until you need to use it? The set the focus there and once the proper item is selected, make it invisible again and fill in the value.

Much easier than trying to use another form and get the value back. Doesn't work as nice as a pop-up, but it's easier. Otherwise you'll need to pass the value back to the main form in a session variable or in the url.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
part of the problem is you're confusing technologies. asp.net is just a framework for fulfilling uri request/response. it's not a programming language. VB is a programming language (probably what your using to code the system).

another problem is you're fighting with the webforms model. webforms is really just an overly complex html rendering engine. this is often forgotten because webforms abstracts everything web away from the model.

you are on the right track with limiting the potential of 100's of lookup values. there is another extender control in the MS AJAX library and I can't think of it's name right now. basically is works like this:
within a textbox after entering X number of characters a webservice will return the matching results. so your search by spelling the value you're looking for. this may be a better option than filtering a grid.

while ArtieChoke option of hiding the grid will work it will be a huge drain on preformance because your a loading a huge amount of data that may or may not be required. with ERP preloading that much data (especially with a gridview) can greatly hinder preformance.

if the grid is a simple lookup up to populate another control, consider droping the gridview in favor of a repeater with custom paging (or a listview found in vs08). if you use the built-in paging provided with a gridview the preformance will still suffer because all 1000 values are loaded into viewstate (which is rendered to the client).

if this is a large scale web-based ERP. I wouldn't use Webforms at all. I would go back to the basics of raw html and provide the data via a model-view-controller framework like Castle's MonoRail or MSMVC (.net 3.5)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
You can use javascript for this. You can popup a window, and as Jason suggested, use a repeater instead of a gridview. Upon selection, you close the popup window and populate the textbox with the selected value. There are many examples on line. For more help, you can post in the javascript forum. forum216
 
Thanks very much for the help. I feel much better about approaching the issue now. I'll be sure to let you know if I run into anything else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top