ASP.NET - How to write select query based on textbox value in TextChanged event

Asked By yashalakshmi on 04-Jul-13 04:16 AM
Hi all.,
 I have written a stored procedure as follows:
 SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetCustomerReport]
@compid int,
@StatementType int,
@value varchar 
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

    If @StatementType=1
    Begin
SELECT Name,ContactNo from ContactDetails
    End 
    Else If @StatementType=2 
    Begin
        SELECT Name,ContactNo from ContactDetails where Name like @value+'%'
    End
End

I called this storedprocedure in page load event and textbox's textxhanged event.
now suppose my table values are as follows: Name ContactNo  a 123 aa 234 o/p i expect is:
if textbox.value=a, both 'a' and 'aa' contactno should be displayed.
if textbox.value=aa, only 'aa' contactno should be displayed.
if textbox.value=ab,none values should be displayed.
Robbe Morris replied to yashalakshmi on 04-Jul-13 05:01 PM
set @value = @value + '%'

 SELECT Name,ContactNo from ContactDetails where Name like @value