[Last Call] Learn how to a build a cloud-first strategyRegister Now


Opening Popup Window in ASP.NET to Search, Select, and Position on a Specific Record in a DataGrid.

Posted on 2005-04-17
Medium Priority
Last Modified: 2012-08-13
Hi Experts,

I have an ASP.NET application written in VB.NET.  The main page lists customers via a datagrid that is populated from a SQL Server 2000 database.  The dagagrid allows paging (10 customers/page) and sorting using the builtin capabilities of the datagrid.  Currently there are approcimately 250 customers that get returned and placed in a dataset.  The dataset is used as the datasource for the datagrid on the main page.

Recently, the user asked for a popup window to allow them to search via the lastname.  They want the popup window as follows WITHOUT requiring a postback to the server.  They want to use the customer data that has been returned and that is in the dataset. Here is the scenario:

     1.  From the main window, click on an image control to open up the search window as a modal dialog (this app only runs on IE)
     2.  When the popup opens, enter a search string to find the customer on lastname.  
     3.  Searching is from left to right based on the number of characters entered.
     4.  Search on the lastname in the dataset displaying the results in a datagrid that is also in the popup window.  
     5.  Vertical scrolling is required in the popup window WITHOUT paging.
     6.  Select the desired record from the popup window datagrid and close the popup window.
     7.  Return the record selected and select the record in the datagrid on the main page.  
     8.  If the record selected isn't visible in the current page, go to the page where it is located and make it the current page.  
     9.  DO NOT change the sort sequence of the main datagrid.

I'm OK with all items except 4, 6, 7, and 8.  Any ideas on how to complete this?

Question by:ClaySeifert
  • 2
  • 2

Author Comment

ID: 13805806
Hi Experts

I was tired last night when I wrote the issue and it contains a mistake.  I said postback when I meant not having to re-query the database.  The application that this is for uses a copy of the database that gets updated nightly.  Sorry for the mis-type :<)

Expert Comment

ID: 13823403
Just create a datatable and populate it on load.  You will then just bind and rebind to the same datatable/dataset based on the users paging etc.  Something I don't know for sure is if you can easily change a the attributes of a row in a daatgrid or if I have always wound using a datalis/repeater for this.  Assuming you can use a datagrid:
 Item 4 becomes like your existing page
 Item 6 is a simple Add.Attribute which would contain a window.close(); or container.close depending on how you call you popup window(I would look at javascript popup calendars to emulate that functionality)
 Item 7 & 8 could be as simple as populating a textbox containing an onChange event which would dynamically change the class name used in a particular row or alternatively have an add.attribute javascript that changes the of the row used in the datagrid from the popup window and then you can use the class attribute to determine what was selected, (but more than likely you would have to do a postback and repopulate the datagrid to display the selected record because it may not be on the displayed screen).

If you have to use a datalist, the same load premise will apply but you may need to manually recreate some of the datagrids functionality using ItemTemplates in your DataList.

If you still have problems with specifics in doing this let me know and I'll try to find some example code to post for you.

Good Luck,

Author Comment

ID: 13909285
Jeff has outlined a valid approach to solve this problem -- but I haven't been able to get it to work.  I'm stumbling with positioning the page containing the selected record so it is visable in the datagrid and subsequently selecting the record.  The selection of the record forces a postback using the built in event handler which I don't want.  Does anybody have javascript that can emulate my needs without forcing a postback?


Accepted Solution

jcrumble earned 1500 total points
ID: 13909952
If you want the page postitioned in the datagrid, something you might consider using is innerHTML, divs, iframes, or a panel inside the datagride as opposed to poping up a new page.  That would let you control the positioning without getting deep into DHTML that may not be interpreted by all browsers the same way.  As far as a postback goes your kind of stuck there unless you want to manually build your HTML tables from a javascript whenever the user searches the page.  This could work if you aren't using a ton of records.  Here's anpther discussion on JavaScript arrays that might help you with searching the array http://www.experts-exchange.com/Web/Q_21404488.html#13897408.  Check out www.irt.org for other javascript that could help you emulate the datagrid capabilities on the client.

Good Luck,

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question