I have create a gridview and a SqlDataSource, which has parameter in the where clause, which has a source in a dropdown menu. That works fine.

I also have an input textfield. I would like the value from it to set the parameter in the same SqlDataSource, when an onclick event occurs, and then refreshing the gridview.

How can this be done?

share|improve this question
feedback

1 Answer

Yes, as shown below you add it as a parameter to the sql data source:-

<SelectParameters>
   //...existing paramaters
    <asp:ControlParameter Name="SprocArgName" ControlID="txtBoxName" PropertyName="Text" Type="String" />
</SelectParameters>

Just treat an empty string as no filter in your sql. Otherwise you will have to add a checkbox to say you want to use the text box filter, you can then add a second controlparamater to the sqldatasource and check for that bool value.

share|improve this answer
How can I do it in C# through an onlick event? – Borut Flis Dec 24 '12 at 12:49
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.