0

I have created a visual web-part and I have a dropdown list and a gridview on it. on c# I have created a query:

string selected = DropDownList1.SelectedValue;

       query.Query = @"<Where><Eq>
                         <FieldRef Name='Team' />
                         <Value Type='Text'>"+ selected+ @"</Value>
                      </Eq></Where>";

it has 3 menu: 1)small 2)medium 3)large

also in my code I have include AutoPostBack="true" It works fine but it is a problem for every time I change the dropdown value i.e from small to large it refreshes me the page. If I dont use this AutoPostBack="true" it doesn't refresh the page but it wont load the new query! Is there any way to complete this action without refreshing the page?

1 Answer 1

0

You should run the query when a submit button is pressed, or when the dropdown is changed, not on page load.

4
  • I have it running when a dropdown is changed and it refreshes my page Commented Jun 16, 2016 at 15:54
  • Where in your code is AutoPostBack true? Is it on the dropdown?
    – Erin L
    Commented Jun 16, 2016 at 16:22
  • yes it is on the dropdown in XML code Commented Jun 17, 2016 at 11:40
  • So set AutoPostBack to false on the dropdown, and create a method on dropdown change that runs the query and changes any associated values on the page.
    – Erin L
    Commented Jun 20, 2016 at 13:11

Your Answer

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

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