Searching a Database Table from ASP.NET using SQLDataSource - A Challenge!
Mar
1
Written by:
3/1/2010 1:57 PM
I have been immersed in a number of client projects since my last blog post, my apolgies for not blogging more! Today's post is a challenge - sorry no bounty except for a posted solution here and recognition to the person providing the solution.
Suppose I have a table that has Name and ID in my SQL Server database. I want to allow my website users to search this table, using either name or ID. The search results are output to a ASP.NET gridview. The controls used to initiate the search are simply a textbox that stores the search string, a dropdownlist specifying the field to search (name or ID), and a submit button.
How would you create the where clause for the SQLDataSource and do the databinding between the textbox, dropdownlist and the gridview? VB solutions most helpful, but I can also run C# solutions through a converter too.
Happy Coding!