Tendrías que ponerle un "AutoPostBack" al DropDrownList también. Y como dice
jaullo, deberia estar dentro de un UpdatePanel.
Ejemplo del UpdatePanel con DDL´s:
Código aspx:
Ver original<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!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">
<asp:ScriptManager runat="server" ID="scripmanager1"></asp:ScriptManager>
<div><h1>prueba de refresco de elementos en la pagina</h1></div>
<!-- primer dropdownlist con el update panel -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="numero 1"></asp:ListItem>
<asp:ListItem Text="numero 2"></asp:ListItem>
<asp:ListItem Text="numero 3"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="selectedindexchanged" />
</Triggers>
</asp:UpdatePanel>
<!-- segundo dropdownlist con el update panel -->
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList2" EventName="selectedindexchanged" />
</Triggers>
</asp:UpdatePanel>
<!-- tercer dropdownlist con el update panel (este ya no refresca nada y no tiene trigger) -->
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Código c#:
Ver originalPágina c#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add("numero 1");
DropDownList2.Items.Add("numero 2");
DropDownList2.Items.Add("numero 3");
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Add("numero 1");
DropDownList3.Items.Add("numero 2");
DropDownList3.Items.Add("numero 3");
}
}
}
referencia: http://social.msdn.microsoft.com/For...6-6476f86fe617
Saludos,