DropdownList链接到文本框

时间:2016-10-07 14:03:30

标签: c# asp.net ajax asp.net-web-api drop-down-menu

我正在尝试在textBox(字段编号2)和我的ajax htmlEditor(字段编号3)中显示我的下拉列表的selectedIndex。我已经可以在我的下拉列表中显示字段编号1,但我似乎无法在其他框中显示任何内容,我得到的都是错误:(,暗示dataSource没有任何奇怪的项目。这是我的类。

Messages.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Messages.aspx.cs" Inherits="ASF.HC.JobApplication.Admin.Messages" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Messages</h2>    
    <asp:ScriptManager ID="ScriptManager2" runat="server"></asp:ScriptManager>
    <legend>Pick the template to use:</legend>
    <asp:dropdownlist id ="ddlTemplate" runat ="server" Height="38px" Width="397px">
                  <asp:listitem value ="1"> Juan Valdez </asp:listitem >
                  <asp:listitem Value ="2"> Querido bebe</asp:listitem>
                  </asp:dropdownlist >     
    <p>&nbsp;</p>
    <asp:TextBox ID="textDos" AutoPostBack="true" runat="server" MaxLength="40"></asp:TextBox>
            <ajaxToolkit:HtmlEditorExtender ID="textoTemplate" runat="server" TargetControlID="txtDetails" 
                EnableSanitization="false" DisplaySourceTab="true" >               
            </ajaxToolkit:HtmlEditorExtender>
</asp:Content>

Message.aspx.cs

public partial class Messages : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            loadList();
        }

        public void loadList()
        {
            try
            {
                BO.Messages template = new BO.Messages();
                ddlTemplate.DataSource = template.GetAll();
                ddlTemplate.DataValueField = "Title";
                DataSet ds = new DataSet("Templates");
                ddlTemplate.DataSource = ds;
                ddlTemplate.DataBind();
                ddlTemplate.SelectedIndexChanged += DdlTemplate_SelectedIndexChanged;
                textDos.Text = ds.Tables[0].Rows[0]["id"].ToString();
            } catch (Exception e)
            {

            }
        }

        private void DdlTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            //when we change the dropdownlist we need to get the student id and set it to the textbox
            DropDownList mydropdownlist = sender as DropDownList;
            textDos.Text = mydropdownlist.SelectedValue;

        }


    }

整天检查这个错误,没有合理的答案,也无法检测到我做错了什么。

感谢您的协助。

0 个答案:

没有答案