开发者

Gridview SQL Parameter null from javascript/ajax populated dropdownlist

My issue is similar to How to use the Value of a Selected Value from a DropDownList populate开发者_JAVA百科d with AJAX/PHP but I am using ASP.NET, not PHP.

I have a dropdownlist that is populated by another dropdownlist's current value through ajax. So if DDL A is 'NY', DDL B is populated with different data relating to 'NY'. I need that data to be posted back to the server because this affects an SQLDataSource parameter. However, as far as I can tell, the value is always null after postback resulting in the gridview to be empty.

How can I force ASP to read the dropdownlist's current value?


DDL B is populated at client side - there are no elements present in it on server side. That's why on server side, you will not get any value out of control. However, you can always lookup in the request post data - Request.Form[DDLB.UniqueID] to get the selected drop-down value.

Edit: typically, you need to turn page event validation off in scenarios where your server control may post back invalid value (for example, a drop down returning value not present in its options).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜