【发布时间】:2020-02-07 03:34:59
【问题描述】:
我有一个问题,我什至不知道如何开始。我有这个控制器:
HomeController.cs
using dependencies;
namespace Automata.Controllers
{
public class HomeController : Controller
{
public System.Data.DataTable dt_PagosRecibidos = new System.Data.DataTable();
public ActionResult PagosRecibidos()
{
cargarPagosRecibidos();
return View();
}
public void cargarPagosRecibidos()
{
string myVar = "";
String SentaiAppServer = System.Configuration.ConfigurationManager.AppSettings["SentaiAppServer"].ToString();
string sURL = SentaiAppServer + ("app/interfaces/bbva/sp_EstadoCuenta.html?fecha_ini=07/16/19&fecha_fin=07/16/19&interfazado=no&Sucursal=" + myVar + "&");
System.Data.DataSet ds = clsUtilerias.ObtenerDSInterfaceSentai(sURL);
dt_PagosRecibidos = ds.Tables[1];
}
}
}
我也有我的 HTML 下拉列表:
<div class="col-lg-2 col-md-3 form-group pull-right">
<label>Sucursal:</label>
<select id="sucursalTabla" onchange="myFilter()" class="form-control">
<option value="" selected>Filtrar..</option>
<option value="MY">Monterrey</option>
<option value="GD">Guadalajara</option>
<option value="MX">Mexico</option>
<option value="PB">Puebla</option>
<option value="VR">Veracruz</option>
<option value="MD">Merida</option>
<option value="SA">Saltillo</option>
</select>
</div>
如何使控制器中的option value="XX" 等于myVar?
或者有没有其他方法可以使用下拉菜单来更改我在控制器中的对象中的变量?
我需要对日期做同样的事情,
("app/interfaces/bbva/sp_EstadoCuenta.html?fecha_ini=07/16/19&fecha_fin=07/16/19&interfazado=no&Sucursal=" + myVar + "&");
fecha_ini=07/16/19
fecha_fin=07/16/19
这些也可能是变量,例如
starte_date = picker.startdate
end_date = picker.enddate
【问题讨论】:
-
既然您显然在使用 ASP.NET MVC,为什么不直接使用
Html.DropDownListFor?见How to write a simple Html.DropDownListFor()? -
函数
myFilter在哪里? -
@EGC 没有 myFilter 功能,对于复制和粘贴,您有什么建议吗?
标签: c# html asp.net datatable dropdown