|
-
Jul 14th, 2007, 08:57 AM
#1
Thread Starter
Member
Procedure for run two select command
Hi all!
I have table Product includes field : ID,Product,Price and table Customer include field: JID,Name. I want write a procedure SQL for search. In my page Search.aspx (by C#) include a textbox (ID=name) and a DropDownlist ( include two values: Customer and Product) and a Submit button. I want when user type a name into textbox and selected a value in DropDownlist and click submit. If value of DropDownlist = Product then my procedure will run SQL command " Selec * from Product......" . If value of DropDownlist = Customer then my procedure will run SQL " Select * from Customer.....". The result will a GridView. Please help me
-
Jul 14th, 2007, 07:14 PM
#2
Re: Procedure for run two select command
C# Code:
SqlCommand command = new SqlCommand("SELECT * FROM " + myDDL.Text, connection);
Just note that I don't know if a DropDownList has a Text property because I've never used one, but you can substitute whatever returns the displayed value if necessary.
Now, that may change if you want to include the value in the TextBox but you haven't indicated where it comes in.
-
Jul 14th, 2007, 07:46 PM
#3
Re: Procedure for run two select command
jmc is spot on. The .Text property of the DropDownList returns the SelectedValue of the control. Good luck with you project.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|