如何填写as​​p.net ListView控件的EditItemTemplate中的dropdownlist [英] How to fill dropdownlist in EditItemTemplate of asp.net ListView control

查看:89
本文介绍了如何填写as​​p.net ListView控件的EditItemTemplate中的dropdownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在激活编辑时填充ListView EditItemTemplate中的DropDownList。我试过这段代码。但是,EditItem为null,它会抛出NullReferenceException。



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.

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");
            }
        }
    }

推荐答案




美好的一天!!!



Tyr跟随这个......





http:// www .aspsnippets.com / Articles / Find-and-access-controls-in-EditItemTemplate-of-ASPNet-ListView.aspx [ ^ ]


这篇关于如何填写as​​p.net ListView控件的EditItemTemplate中的dropdownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆