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?

0

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

  • I have it running when a dropdown is changed and it refreshes my page – Nderon Hyseni Jun 16 '16 at 15:54
  • Where in your code is AutoPostBack true? Is it on the dropdown? – Erin L Jun 16 '16 at 16:22
  • yes it is on the dropdown in XML code – Nderon Hyseni Jun 17 '16 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 Jun 20 '16 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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