Hi
I am having trouble accessing a DropDownList which is located with a
DataGrid :(
This is the code in my .aspx file:
<asp:DataGrid id=AccountList runat="server" OnEditCommand="EditAccount">
<Columns>
<asp:TemplateColumn HeaderText="Customer">
<ItemTemplate>
<asp:Label Runat=server Text='<% # DataBinder.Eval
(Container.DataItem, "Customer") %>' ID="Label1"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" id="EditCustomer"/>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
In my .aspx.cs file I haved tried the following within the EditAccount
method:
EditAccount(...)
{
AccountList.EditItemIndex = e.Item.ItemIndex;
AccountList.DataBind();
foreach(string customer in allCustomers)
((DropDownList) e.Item.Cells[1].Controls[0]).Items.Add(customer);
}
I also tried:
EditAccount(...)
{
AccountList.EditItemIndex = e.Item.ItemIndex;
AccountList.DataBind();
foreach(string customer in allCustomers)
((DropDownList)
e.Item.FindControl["EditCustomer"]).Items.Add(customer);
}
Can anyone help me on this?
Kind regards and thanx in advance,
Lars Tengstedt
Edlund A/S
Denmark