0

我有 kendodropdown,我想将选定的值从 kendodropdown 填充到单击编辑按钮后的文本框。我使用 mvc.razor。请帮忙。控制器1/视图1

     @(Html.Kendo().DropDownList()
      .Name("labeldropdown")
      .DataTextField("Tasks")
        .DataValueField("ID")
          .OptionLabel("Select label")
         .AutoBind(true)
     .HtmlAttributes(new { @style = "width: 72px;font-size:12px; " })
        .DataSource(source =>
   {   source.Read(read =>
          {
          read.Action("BindStates", "Resource");
       });
        })
        .SelectedIndex(0)
      )

<input type="button" value="New" class="k-button" id="newLabel" />
  <input type="button" value="Edit" class="k-button" id="editLabel" />

控制器1/视图2

 <input type="button" value="OK" class="k-button" id="labelok" /><br />
  <input type="button" value="Cancel" class="k-button" id="labelcancel" />
  @Html.TextBox("labeltxt", null, new { @class = "k-textbox" })
4

1 回答 1

0

尝试这个,

@(Html.Kendo().DropDownList()
      .Name("labeldropdown")
      .DataTextField("Tasks")
        .DataValueField("ID")
          .OptionLabel("Select label")
         .AutoBind(true)
     .HtmlAttributes(new { @style = "width: 72px;font-size:12px; " })
        .DataSource(source =>
   {   source.Read(read =>
          {
          read.Action("BindStates", "Resource");
       });
        })
        .SelectedIndex(0)
      )


     @Html.TextBox("labeltxt", null, new {id = "txtText", @class = "k-textbox" })

    <input type="button" value="Edit" class="k-button" id="editLabel" />

        $("#editLabel").click(function () {

              $("#txtText").val($("#labeldropdown").data("kendoComboBox").value());
              $("#CoutryID").data("kendoComboBox").value();//This is for ID               
              $("#CoutryID").data("kendoComboBox").text();  //This is for text             
        });

所以你必须根据上面的代码设置值。

于 2013-07-16T05:26:38.120 回答