Hi
I have a Listview with EditItemTemplate and DataPager. In this ListView I have a DropDownList in EditItemTemplate. When I go to page 2 in this ListView and hit on Edit Button, DropDownList is empty and doesn't show anything.
The code that display items of DropDownList :
protected void lvDepartments_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (lvDepartments.EditIndex == (e.Item as ListViewDataItem).DataItemIndex)
{
Database db = new Database();
string query = "select CatId,CatName from Category";
SqlCommand smd = new SqlCommand(query, db.sc);
DataTable dt = new DataTable();
dt.Load(smd.ExecuteReader());
DropDownList ddlEditDepartment = (e.Item.FindControl("ddlEditDepartment") as DropDownList);
ddlEditDepartment.DataSource = dt;
ddlEditDepartment.DataTextField = "CatName";
ddlEditDepartment.DataValueField = "CatId";
ddlEditDepartment.Data ...
Go to the complete details ...