Reputation:
I have 1 textbox + 1 button on default.aspx.
and I have 1 listbox on results.aspx.
I want to make a search on SQL based on textbox.text and display in results.aspx.
I'm doing something wrong but can't find my mistake.
Upvotes: 0
Views: 184
Reputation: 31
You are taking the textbox in default.aspx page and calling it in Another page. so u wont get that control.. In order to access the value of that textbox.. u need to create session variable and assign the value to that session variable and can access that variable in another page and by calling that session variable. and use that variable in sql query near 'like'
Upvotes: 0
Reputation: 10818
It looks like you are naming the TextBox from the previous page "SourceTextBox", you then try to access the text via "TextBox1.Text".
If you change TextBox1.Text to SourceTextBox.Text you should have your answer.
EXAMPLE:
cmd.Parameters.AddWithValue("@searchkey", "%" + SourceTextBox.Text);
Upvotes: 1
Reputation: 342
for a start I think it should be
cmd.Parameters.AddWithValue("@searchkey", "%" + SourceTextBox.Text);
Upvotes: 0