Kendo DropdownList未选择绑定值

时间:2014-10-20 10:47:13

标签: c# asp.net-mvc-4 kendo-ui kendo-dropdown

我有一个kendo DropdownList,如下所示。当我的页面加载时,我加载了两次具有不同值的Kendo DDL。我需要的是我想只将最后一次加载的值绑定到我的Kendo DDL中并选择第一个值。我的Kendo DDL使用正确的值绑定,但它不会从上次加载的值中选择第一个值。

@(Html.Kendo().DropDownListFor(m => m.SemesterID)
.HtmlAttributes(new { data_value_primitive = "true", style = "width:320px" })
.OptionLabel("Select Semester Below...")
.Name("SemesterID") 
.DataTextField("SemesterName") 
.DataValueField("SemesterID") 
.AutoBind(true)                 
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("GetSemester", "StudentRSRegistration").Data("loadSemester"); 

            })
            .ServerFiltering(true); client.
        })
.SelectedIndex(0)

这是获取DDL值的方法

public List<StudentRSRegistartionModel> GetSemester(int? ProgrammeID1, int? SpecializationID1, int? SpecializationLevelID1, int? IntakeID1, int? IntakeYear )
    {

                if (!string.IsNullOrEmpty(ProgrammeID1.ToString()) && string.IsNullOrEmpty(SpecializationID1.ToString()))
                {
                    obj = (from tbsr in context.tblSemesterRegistrations
                           join tbintake in context.tblIntakes on tbsr.IntakeID equals tbintake.intakeID
                           where
                           ((tbsr.ProgrammeID == ProgrammeID1) &&
                           ((tbsr.SpecializationID == null)) &&
                           (tbsr.IntakeID == IntakeID1 || !(tbsr.IntakeID.HasValue)) &&
                           (tbsr.IntakeYear == IntakeYear || !(tbsr.AcadamiYear.HasValue)))

                           select new StudentRSRegistartionModel
                           {
                               SemesterID = tbsr.SemesterID,
                               intakeYear = tbsr.IntakeYear,
                               AcadamicSemester = tbsr.AcadamicSemester,
                               Acadamicyear = tbsr.AcadamiYear,
                               IntakeCode = tbintake.IntakeCode,
                               SpecializationID = tbsr.SpecializationID,

                           }).OrderByDescending(o => o.SemesterID).ToList()

                                                           .Select(tb => new StudentRSRegistartionModel()
                                                           {
                                                               intakeYear = tb.intakeYear,
                                                               SemesterID = tb.SemesterID,
                                                               IntakeCode = tb.IntakeCode,
                                                               SemesterName = "Year " + tb.Acadamicyear + ": Semester " + tb.AcadamicSemester + ": Intake " + tb.IntakeCode,
                                                           }).OrderBy(o => o.SemesterName).ToList();

                }




                return obj;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

my DDL is now like this, But I want to select first value

此方法在两个时间内都给出了正确的值。任何人都知道为什么这个剑道DDL没有正确选择...... Thnaks ....

0 个答案:

没有答案