J'ai une colonne dans un datagrid comme cela
Et j aimerais lier à "EqtDropDownListAdd" un evenement SelectedIndexChanged
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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>
EqtDropDownListAdd est declaré pour toute la classe
Il herite de DropDownList et a AutoPostBack = true
Il est rempli lors du itemdatabound
Le probleme est que je n'arrives pas à garder l'evenement sur ce dropdownlist
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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); } }
![]()
Partager