Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to fill a DropDownList in my ListView EditItemTemplate when Edit is activated. I tried this code. But, The EditItem is null, and it throws a NullReferenceException.

C#
protected void ListView3_ItemEditing(object sender, ListViewEditEventArgs e)
    {
        if (e.NewEditIndex >= 0 && ListView3.Items[e.NewEditIndex].ItemType == ListViewItemType.DataItem)
        {
            object _edSubPro = ListView3.EditItem.FindControl("edListSubProject");
            if (_edSubPro != null && _edSubPro is DropDownList)
            {
                DropDownList _edSubProDP = (DropDownList)_edSubPro;
                BindDropDownList(_edSubProDP, "select  SubProjectID, (LEFT(SubProjectCode + REPLICATE(' ' , 7), 7) + ' | ' + SubProjectName) AS SubProjectName  from SubProject", "SubProject", "SubProjectName", "SubProjectID");
            }
        }
    }
Posted

1 solution

 
Share this answer
 
Comments
Yesudass Moses 26-May-15 5:53am    
Wow... Thanks so much dear friend. This saved my life. Its working...
[no name] 26-May-15 6:00am    
welcome Moses

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900