Getting value from a dropdown list that was populated with AJAX

前端 未结 2 629
春和景丽
春和景丽 2021-01-01 05:01

I had populated an ASP.net dropdown list with AJAX now I need to get the Id to store in into the database in a C# method, (I\'m using LINQ)

This is my webmethod

相关标签:
2条回答
  • 2021-01-01 05:27

    You can't get selected value from DropDownList if you adding options in javaScript. You can try the following

    string selectedValue = Request.Form[ddlLanguage.UniqueID];
    

    This question may be useful also.

    0 讨论(0)
  • 2021-01-01 05:33

    If you populate the value of dropdown via ajax than it can't be available on Server Side because the page doesn't postback during ajax request.

    In order to get the value of dropdown in C# use below snippets :

    String _value = Convert.ToString(Request[ddlLanguage.ClientID]);
    

    Hope this will help !!

    0 讨论(0)
提交回复
热议问题