小编bla*_*ner的帖子

on select change事件 - Html.DropDownListFor

我有两个下拉列表.第一个选定的值加载另一个.当我在控制器中有辅助方法时,我该怎么做?

@using (Html.BeginForm())
{
<div>
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td><b>Select a District:</b></td>
            <td>@Html.DropDownListFor(m => m.DistrictId, ViewData["DMManagers"] as IEnumerable<SelectListItem>, "Select One")</td>
        </tr>
        <tr>
            <td><b>Select a TM:</b></td>
            <td>@Html.DropDownListFor(m => m.TMId, ViewData["TMManagers"] as IEnumerable<SelectListItem>, "Select One")</td>
        </tr>
    </table>
</div>
}

private void LoadDistrictManagers()
{
    var _DMS = (from c in SessionHandler.CurrentContext.ChannelGroups
                join cgt in SessionHandler.CurrentContext.ChannelGroupTypes on c.ChannelGroupTypeId equals cgt.ChannelGroupTypeId
                where cgt.Name == "District Manager"
                select new { c.ChannelGroupId, c.Name }).OrderBy(m => m.Name);
    ViewData["DMManagers"] = new SelectList(_DMS, "ChannelGroupId", "Name");
}

private void LoadTerritoryManagers(int …
Run Code Online (Sandbox Code Playgroud)

c# razor asp.net-mvc-3

23
推荐指数
1
解决办法
8万
查看次数

在IE7中未定义JSON

它在chrome,firefox和IE8中运行良好.但在IE7上出现错误.这是我的jquery onchange事件.

$('select#NationId').change(function () {
        var nationId = $(this).val();
        $.ajax({
            url: 'LoadAreas',
            type: 'POST',
            data: JSON.stringify({ nationId: nationId }),
            dataType: 'json',
            contentType: 'application/json',
            success: function (data) {
                $('select#AreaId').get(0).options.length = 0;
                $('select#AreaId').append('<option value="0">Select All</option>');
                $.each(data, function (val, Areas) {
                    $('select#AreaId').append('<option value="' + Areas.Id + '">' + Areas.Name + '</option>');
                });
            }
        });
    });
Run Code Online (Sandbox Code Playgroud)

调节器

[HttpPost]
    public ActionResult LoadAreas(int nationId)
    {
        var _Areas = (from c in SessionHandler.CurrentContext.ChannelGroups
                      join cgt in SessionHandler.CurrentContext.ChannelGroupTypes on c.ChannelGroupTypeId equals cgt.ChannelGroupTypeId
                      where cgt.Name == "Area" && c.ParentChannelGroupId …
Run Code Online (Sandbox Code Playgroud)

asp.net internet-explorer-7 asp.net-mvc-3

23
推荐指数
1
解决办法
2万
查看次数

LINQ to Entities无法识别方法'Double Parse(System.String)'方法,并且此方法无法转换为存储表达式

我尝试运行报告时收到错误.问题出在这里:model.Referring = Math.Round(_newSurveyResult.Select(m => string.IsNullOrEmpty(m.Question1) ? 0 : Double.Parse(m.Question1)).Average());

public class SummaryDetails
{
    public int ChannelId { get; set; }
    public int ChannelGroupId { get; set; }
    public string Question1 { get; set; }
    public string Question2 { get; set; }
    public string Question3 { get; set; }
    public string Question4 { get; set; }
    public int OrganizationId { get; set; }
}

public ActionResult AreaManager(AreaManagerModel model)
{
    model.ShowCustomerReport = false;
    model.ShowSurveyReport = true;
    LoadModelVariablesonPostBack(model, 8);
    var _newSurveyResult = …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework

17
推荐指数
1
解决办法
2万
查看次数

使Html.TextBoxFor看起来像Label

我想让MVC 3中的文本框显示为标签.我仍然显示边界的代码.

<p>@Html.TextBoxFor(m => m.PostcardsperWeek, new Dictionary<string, object>() { 
   { "id", "txtPostcardPerWeek" }, 
   { "readonly", "true" }, 
   {"class", "TextBoxAsLabel"} })
</p>
Run Code Online (Sandbox Code Playgroud)

CSS:

.TextBoxAsLabel
{
   border: none;
   background-color: #fff;
   background: transparent;
}
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-3

9
推荐指数
1
解决办法
2万
查看次数

我如何使用此linq查询在MVC中使用foreach循环显示数据

我不知道如何实现这一目标.我想在视图中使用foreach循环以表格格式显示数据.此数据将来自linq查询,该查询使用3-4个表并选择要显示的不同字段.不知道如何返回这个,因为我得到一个匿名类型错误.

var info = from s in context.LennoxSurveyResponses
                       join customers in context.Customers on s.SurveyCode equals customers.SurveyCode
                       join lists in context.CustomerLists on customers.ListId equals lists.ListId
                       join dealer in context.Channels on lists.ChannelId equals dealer.ChannelId
                       where dealer.ChannelId == id
                       select new
                       {
                           ResponseId = s.ResponseId,
                           CustomerFirstName = customers.FirstName,
                           CustomerLastName = customers.LastName,
                           CustomerTestimonial = s.Question5Answer
                       };
Run Code Online (Sandbox Code Playgroud)

我的模型必须声明什么才能传递给视图?

asp.net-mvc-3

1
推荐指数
1
解决办法
5393
查看次数