Asp.Net MVC |下拉列表数据提取

问题描述

如何将相关的sql数据拉到下拉列表中进行控制?下拉列表应默认为“m.alici”数据。

project(proj1)

add_library(proj1 src.cpp)
# This are private include files,whoever uses this library does not need them
target_include_directories(proj1 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
# These are public,needed both by this target and by whoever uses it.
target_include_directories(proj1 PUBLIC
    # This is used when building the target
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/public/include>
    # This is used when the target is installed
    $<INSTALL_INTERFACE:include>)
# Instead of asking directly for a language standard we ask for a compiler feature. We make this public so whoever depends on this target knows they also need this feature.
target_compile_features(proj1 PUBLIC cxx_strong_enums)
# As above,but this is needed only by this target during the build.
target_compile_features(proe1 PRIVATE cxx_lambdas)

# Add an alias,users can use target_link_libraries(target PRIVATE|PUBLIC proj::proj1) to add this target as a dependency (this will propagate all the PUBLIC include paths,compile options,compile features,dependencies,etc.
add_library(proj::proj1 ALIAS proj1)

解决方法

在您的控制器中创建一个 ViewBag。注意最后一个参数可以加上默认值。

 ViewBag.Example = new SelectList((from s in _cs.example.OrderBy(s => s.Code)
 select new { ID = s.Id,FullDescription = s.Code + " - " + s.Description }),"ID","FullDescription","m.alici");

然后在你看来

 @Html.DropDownListFor(m => m.Durum,(SelectList)ViewBag.Example,new { @class = "form-control" })

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...