Bonjour,

je cherche a changer mettre DDL dans une colonne en mode Edition , (colonne titre Film)
voila mon DataGrid
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
16
17
18
19
20
21
22
23
24
25
26
27
 
<asp:DataGrid id="MyDataGrid" runat="server" oncancelcommand="DataCancel" onupdatecommand="DataUpdate" AutoGenerateColumns="False" ForeColor="Black" BorderStyle="None" GridLines="Vertical" BorderWidth="1px" BorderColor="#DEDFDE" BackColor="White" CellPadding="4" AllowPaging="True">
<FooterStyle backcolor="#CCCC99"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#6B696B"></HeaderStyle>
<PagerStyle horizontalalign="Right" forecolor="Black" backcolor="#F7F7DE" mode="NumericPages"></PagerStyle>
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#CE5D5A"></SelectedItemStyle>
<AlternatingItemStyle backcolor="White"></AlternatingItemStyle>
<ItemStyle backcolor="#F7F7DE"></ItemStyle>
<Columns>
<asp:editcommandcolumn Edittext="Edit" canceltext="Cancel" updatetext="OK" />
<asp:TemplateColumn HeaderText="Image">
     <ItemTemplate>
    <asp:Image ImageUrl='<%# "../../central/affiche/" + DataBinder.Eval(Container.DataItem, "source") %>' runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Titre du Film">
<ItemTemplate>
<asp:Label runat="server" text='<%# DataBinder.Eval(Container.DataItem, "titre") %> ' /> 
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Edition">
<EditItemTemplate>
<asp:DropDownList ID="oDropDownList" Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
le code de ma commade Edit
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
protected void MyDataGrid_Edit(Object sender, DataGridCommandEventArgs e)
      {
          MyDataGrid.EditItemIndex = (int)e.Item.ItemIndex;
          OleDbCommand Mycommande = new OleDbCommand("select id, titre from film", myConnection);
          oDropDownList.DataSource = OleDbCommand.ExecuteReader();
          oDropDownList.DataValueField = "id";
          oDropDownList.DataTextField = "titre";
          oDropDownList.DataBind();
 
    BindGrid();
      }
j'ai ce message d'erreur
Compiler Error Message: CS0246: The type or namespace name 'oDropDownList' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 53: MyDataGrid.EditItemIndex = (int)e.Item.ItemIndex;
Line 54: OleDbCommand Mycommande = new OleDbCommand("select id, titre from film", myConnection);
Line 55: oDropDownList.DataSource = OleDbCommand.ExecuteReader();
Line 56: oDropDownList.DataValueField = "id";
Line 57: oDropDownList.DataTextField = "titre";
Et pourtant je mets bien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
<EditItemTemplate>
<asp:DropDownList ID="oDropDownList" Runat="server" />
</EditItemTemplate>
j'aimerais savoir ou je me suis trompée

merci