2

whats the diffrence btw this two SqlDataSource1?

<SelectParameters>
                <asp:Parameter Name="user"  />

</SelectParameters>

SqlDataSource1.SelectParameters("user").DefaultValue = "some value";

SqlDataSource1.SelectParameters("@param",user);

When i use

SqlDataSource1.SelectParameters("user").DefaultValue = "some value";

it works but SqlDataSource1.SelectParameters("@param",user); doesn't:

1
  • @ninjacoder - you're mixing vb syntax with that of C#, tag your question with either of the language along with the current tag Commented Feb 9, 2012 at 8:48

2 Answers 2

3

In the selecting event of the SqlDataSource control pass the value to the to the parameter:

 protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
  {
   e.Command.Parameters["@user"].Value="value";
  }
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks nuux do i need to add this too <SelectParameters> <asp:Parameter Name="user" /> </SelectParameters>
ofcourse yes, you need it to add to the SqlDataSource control as you did it already I think
0

I think you should use smth. like this:
SqlDataSource1.SelectParameters.Add("@param",user);

that has some overloads.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.