[ASP.Net / C#] Ecouteur sur Dropdownlist créé dynamiquement
:salut:
J'ai une colonne dans un datagrid comme cela
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Label Runat="server" ID="LabelType" Text="Type" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label runat="server" ID="LabelTypeItem" Text='<%# DataBinder.Eval(Container, "DataItem.type") %>' />
</ItemTemplate>
<FooterTemplate>
<prospectmgt:EquipmentTypeDropDownList Width="100px" Runat="server" ID="EqtDropDownListAdd"></prospectmgt:EquipmentTypeDropDownList>
</FooterTemplate>
<EditItemTemplate>
<prospectmgt:EquipmentTypeDropDownList Width="100px" Runat="server" ID="EqtDropDownListUpdate"></prospectmgt:EquipmentTypeDropDownList>
</EditItemTemplate>
</asp:TemplateColumn> |
Et j aimerais lier à "EqtDropDownListAdd" un evenement SelectedIndexChanged
EqtDropDownListAdd est declaré pour toute la classe
Il herite de DropDownList et a AutoPostBack = true
Il est rempli lors du itemdatabound
Code:
1 2 3 4 5 6 7 8 9 10
|
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
EqtDropDownListAdd = (EquipmentTypeDropDownList)e.Item.FindControl("EqtDropDownListAdd");
EqtDropDownListAdd.IdSubsidiary = long.Parse(Session["Sub"].ToString());
EqtDropDownListAdd.SelectedIndexChanged += new EventHandler(EqtDropDownListAdd_SelectedIndexChanged);
}
} |
Le probleme est que je n'arrives pas à garder l'evenement sur ce dropdownlist :roll:
:yaisse2::king: