html.dropdownlist选中的值如何在后台获取?急!!

问题描述

html页面:<span>年:@Html.DropDownList("Year")后台:privatevoidGetYear(){List<SelectListItem>yearList=newList<SelectListItem>();intfirstYear=DateTime.Now.Year;for(inti=0;i<10;i++){yearList.Add(newSelectListItem{Text=(firstYear-i).ToString(),Value=(firstYear-i).ToString()});}ViewData["Year"]=yearList;}当我在前台有提交动作的时候怎么把dropdownlist选中的值在后台获取

解决方案

解决方案二:
我是来帮顶学习的。不是ranatserver的控件能取吗?我就知道用jspost上来,估计也不是你要的解决方案
解决方案三:
dropdownlist.selectedvalue就是选中的值;dropdownlist.selectedindex就是选中项目的索引;
解决方案四:
引用2楼linyustar的回复:

dropdownlist.selectedvalue就是选中的值;dropdownlist.selectedindex就是选中项目的索引;

能具体直接点告诉我精准的代码就好了毕竟我菜鸟

时间: 2024-08-02 17:14:05

html.dropdownlist选中的值如何在后台获取?急!!的相关文章

IE8下Jquery获取select选中的值post到后台报错问题_jquery

我们一般使用jquery获取select时,一般这么用: <select id='a'> <option selected='selected' value='1'> </select> var selectedValue = $("#a").val(); 在非IE8下,selectedValue的值为"1",typeof selectedValue 为"string". 在IE8下,selectedValue

GridView更新时怎么把DropDownList选中值更新回数据库中???

问题描述 研究了两天把GridView中的DropDownList二级联动做好了,打开页面时DropDownList当前选中值也做好了,现在只差一步在GridView更新时子DropDownList把选中的值更新回数据库中的s_ID字段中去,应该怎么做?(子DropDownList的ID为ddl_SubDept)下面是前台及cs代码前台代码:<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPag

jquery获取到复选框选中的值,值为数值类型,怎样通过ajax 传到后台,后台怎样接送

问题描述 jquery获取到复选框选中的值,值为数值类型,怎样通过ajax 传到后台,后台怎样接送 求救,困扰了一天了, 急急急急急急急急急急急急,这个问题描述也太坑了吧. 解决方案 <!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js"> </script> <script> function getCheck(){ var

wpf datagrid如何获取DataGridCheckBoxColumn选中的值,后台如何判?

问题描述 wpf datagrid如何获取DataGridCheckBoxColumn选中的值,后台如何判? ,这个后台如何判断是否选中,并且获取选中的那一列.

asp.net中js+jquery添加下拉框值和后台获取示例_实用技巧

复制代码 代码如下: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type

代码-js怎么把值传递到后台

问题描述 js怎么把值传递到后台 <script type="text/javascript"> var cha = 10; function chongChouQu() { window.location = "suiJi.action"; } function checkChecked() { var ipts = document.getElementById('tableid').getElementsByTagName('input'), ch

checkbox-jQuery ajax 获取 c:foreach 遍历的cheakbox复选框选中的值

问题描述 jQuery ajax 获取 c:foreach 遍历的cheakbox复选框选中的值 <div class=""hh1""><div class=""hh""><div class=""box""><div id=""1"" class=""leftbox"&quo

一个查询功能,如何根据checkbox选中的值到数据库查询对应的字段。

问题描述 一个查询功能,如何根据checkbox选中的值到数据库查询对应的字段. 之前是用的下拉框,即单选,现在想改成用checkbox多选,不知道怎么写. 把checkbox的name都写成一样的,然后 String[] checkbox = request.getParameterValues("")? 解决方案 name写成一样是对的 你可以拿到参数值后输出一下看看是如何分割的 然后再做处理 也可以你在前台提交前通过js处理好你的参数 再提交到后台 解决方案二: 可以前台定义一个

easyui-easy ui怎么把table中的值提价到后台啊?

问题描述 easy ui怎么把table中的值提价到后台啊? 框架是Struts2,点击add,添加一行,然后我在后台定义了全局变量code,但是表单提交过去后,没有接到任何的值. 谁知道这是咋回事? 下面是原型demo,哪位大神帮我改下,改成能提交到后台的,因为我怀疑是我写的问题 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Row Editing i