日期:2014-05-17  浏览次数:20396 次

UpdatePanel中DropDownList无反应
前台代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestDroplist.aspx.cs" Inherits="TestDroplist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID ="cbDep" />
            </Triggers>
            <ContentTemplate>
                <asp:DropDownList ID="cbDep" runat="server" AutoPostBack ="true" 
                    onselectedindexchanged="cbDep_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:DropDownList ID="cbMaj" runat="server" AutoPostBack ="true">
                </asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>



后台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class TestDroplist : System.Web.UI.Page
{
    DataTable GetDataTable(string sql)
    {
        DataTable dt = null;
        try
        {
            SqlConnection Conn = new SqlConnection("Data Source=127.0.0.1;database=olpv;uid=sa;pwd=hxyw801102");
            Conn.Open();
            SqlCommand Cmd = new SqlCommand(sql, Conn);
            dt = new DataTable();
      &n