Visual Studio ASP.net querstion

Discussion in 'OT Technology' started by elevator, Dec 31, 2007.

  1. elevator

    elevator The tenants think it's wonderful! ヽ(´ OT Supporter

    Joined:
    Mar 25, 2005
    Messages:
    10,967
    Likes Received:
    0
    Location:
    Houston, TX
    I cannot, for the life of me, find a simple tutorial on how to create a search page and list the results from an sql db in gridview. When I go to the page, I just want to see the fields and a button and then I type something in and the gridview appears with the results. I have my SQL statements ready, but I don't know how to make this happen! This seems so simple! Is there a tutorial someone could direct me to?
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    that is extremely simple. Have you at least created your form using the .Net controls? (it's a WYSIWYG editor, so if you haven't completed this I recommended you get a book and learn the basics)
     
  3. elevator

    elevator The tenants think it's wonderful! ヽ(´ OT Supporter

    Joined:
    Mar 25, 2005
    Messages:
    10,967
    Likes Received:
    0
    Location:
    Houston, TX
    Yep. And I has a book and I have been watching ASP.net tutorial videos, but I cannot find a single one on searching! My web app already enters data (not using gridview) and edits it. This works, but I get all the records in the database upon page loading. If I enter in text in the boxes and press Search, it refreshes the page and lists the results. I don't want all the records to pop up on page load!
    [​IMG]
     
  4. Wanderlei

    Wanderlei New Member

    Joined:
    Nov 13, 2007
    Messages:
    11
    Likes Received:
    0
  5. elevator

    elevator The tenants think it's wonderful! ヽ(´ OT Supporter

    Joined:
    Mar 25, 2005
    Messages:
    10,967
    Likes Received:
    0
    Location:
    Houston, TX
    But I don't really want to filter the data, I want to only return certain records. I don't want the table to even show up until I click search.
     
  6. Wanderlei

    Wanderlei New Member

    Joined:
    Nov 13, 2007
    Messages:
    11
    Likes Received:
    0
    You do want to filter data on owner name, owner address or contact name. If you don't filter it all table data will be returned. You filter on those fields and then only the correct records will be shown.

    You can databind in the code if you want the table to be blank until the search is run. You can also put it on a panel whose visibility is only turned on after the search is run if you dont even want to see the table headers or footers before you click on search.
     
  7. elevator

    elevator The tenants think it's wonderful! ヽ(´ OT Supporter

    Joined:
    Mar 25, 2005
    Messages:
    10,967
    Likes Received:
    0
    Location:
    Houston, TX
    My current program state retrieves all the records and displays them on page load in the GridView. Then I type in the fields and hit the button and it filters the table. I think it is just wasteful to get every record when all I want is one or two.

    How can I keep the table blank until I hit the button? Visibility isn't necessarily the problem. I don't want to waste the resources of returning every record (eventually from about 40,000 of them) when I only want one or two.

    Right now, the SQLDataSource is configured to return all records WHERE the 3 search fields (name, address, contact name) are LIKE the corresponding columns in the record. The default value in all three fields is the wildcard (%) because I don't want to have to enter data in all of them to return records. Thus, on page load, it returns ALL records in the database because of the wildcard is the default value. I am probably going about this wrong, but I don't know what else to do?
     
  8. elevator

    elevator The tenants think it's wonderful! ヽ(´ OT Supporter

    Joined:
    Mar 25, 2005
    Messages:
    10,967
    Likes Received:
    0
    Location:
    Houston, TX
    OK, well I get the results I want by not having the gridview visible until after I click the button (sets it to visible = true). But will this majorly affect performance since it is getting all the records in the database (which could be fairly large, ~40k records). It gets all the records because on page load, nothing is in the search fields and so I default value them all to the wildcard %. If I don't enable paging, does it still get all the records?
     

Share This Page