DropDownList not showing data

D

Darren

hi

i have got a dropdownlist in a templatecolumn and I am
trying to load it with values.

this is the code in the testGrid_EditCommand function

testGrid.EditItemIndex = e.Item.ItemIndex;
DropDownList list =
(DropDownList).Item.FindControl("employees");
// The dropdownlist is not found

list.DataSource = employeeList.DataSource;
//employeeList is another dropdownlist on the page


also i have tried by specifying the datasource in the html

<EditItemTemplate>
<asp:DropDownList ID="employees" Runat=server
OnSelectedIndexChanged="employees_SelectedIndexChanged"
DataSource='<%# employeeList.DataSource%>'
DataTextField="Name" DataValueField="Name">

I have also tried using methods in the datasource which
return data from the database,

nothing works...only an empty list is displayed


I would appreciate any help

thanks
 
A

avnrao

You should be adding this code in testGrid_ItemCreated (ItemCreated event)
method.

if(e.Item.ItemIndex == ListItemType.EditItem)
{
DropDownList list = (DropDownList).Item.FindControl("employees");
// The dropdownlist is not found
list.DataSource = employeeList.DataSource;
}

hth,
Av.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top