1

I have created a cascading dropdownlist using jquery and a webservice in my asp.net website. I have changed the EnableEventValidation="false". I am not getting the selected value which i am binding using jquery on save event.

This is the code I am using to select the value.

int stateid = Convert.ToInt32(ddState.SelectedItem.Value);

neither I am getting ddState.SelectedValue. Both are returning blank.

5
  • 4
    I think we need more code. This snipet is not enough. Commented Oct 13, 2011 at 14:34
  • At least try to provide correct syntax... Commented Oct 13, 2011 at 14:58
  • You need to post the code that shows how the DropDownList is being bound to the data. Commented Oct 13, 2011 at 15:03
  • possible duplicate of unable to get value from asp.net dropdownlist on page submit Commented Oct 13, 2011 at 16:04
  • You got a perfectly workable answer to your last question. Please don't ask nearly the same question twice hoping for different answers. Commented Oct 13, 2011 at 16:05

1 Answer 1

1

Because you're manipulating the select list on the client with jQuery it's going to throw off your viewstate, ASP.NET won't be able to track it so that's why you're seeing the behavior of the blank value being returned.

The easiest way around this is just to look at Request.Form(ddState.id) (or Request.Querystring if you're GETing, which you shouldn't be). Then grab out the value from there.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes I'm starting to relaize this the hard way. I was trying to get away from using UpdatePanels and rely on client side scripting to handle populating things. Problem is, web forms are so tied into ViewState that those control values don't exist even server side later and it's a real mess. Back to UpdatePanels I think...

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.