asp.net disappearing data from Dropdownlist inside listview when loading from DataTable
Posted
by piotrmichal
on Stack Overflow
See other posts from Stack Overflow
or by piotrmichal
Published on 2010-06-15T10:21:29Z
Indexed on
2010/06/15
10:22 UTC
Read the original article
Hit count: 275
Hello I have a problem with dropdowllist ddl1 that is inside of insertitem of listview. I populate it from table on page load. In Page_load I have:
if (!Page.IsPostBack)
{
ListView1.DataBind();
InsDropDownList3.DataSource = GetAllPlayersName();
InsDropDownList3.DataBind();
}
DropDownList ddl1 = (DropDownList)ListView1.InsertItem.FindControl("InsDropDownList1");
if (ddl1 != null)
{
DataTable t = GetAllPlayersName();
ddl1.DataSource = t;
ddl1.DataBind();
}
When I select a row in listview or edit it data from dropdownlist in insertitem row disappears - list became empty until I close page and open again. There is another InsDropDownList3 outside of listview and there is no problem with this one. Why one is loosing data and the other one not? As I understand ddl1 should even get data every time page loads.
© Stack Overflow or respective owner