Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ASP.NET从edititemtemplate中定义的“代码隐藏”下拉列表中访问选定值?_Asp.net_Drop Down Menu - Fatal编程技术网

如何使用ASP.NET从edititemtemplate中定义的“代码隐藏”下拉列表中访问选定值?

如何使用ASP.NET从edititemtemplate中定义的“代码隐藏”下拉列表中访问选定值?,asp.net,drop-down-menu,Asp.net,Drop Down Menu,我在Edititemtemplate中有一个DropDownlist。我想从代码隐藏中访问选定的值 我的aspx <EditItemTemplate> <asp:DropDownList ID="ddlcountry" runat="server"> <asp:ListItem Text="Select Country" Value="0" disabled selected></asp:ListItem> <asp:ListItem Tex

我在Edititemtemplate中有一个DropDownlist。我想从代码隐藏中访问选定的值

我的aspx

<EditItemTemplate>
<asp:DropDownList ID="ddlcountry" runat="server">
<asp:ListItem Text="Select Country" Value="0" disabled selected></asp:ListItem>
<asp:ListItem Text="india" Value="1"></asp:ListItem>
        </asp:DropDownList>
</EditItemTemplate>

尝试
stringcountry=((DropDownList)e.Item.FindControl(“ddlcountry”))。SelectedValue@Suprabhat:它不起作用,还有其他方法吗?关键字“Item”不起作用work@Suprabhat:是的,'item'不支持,它显示错误:它不工作,还有其他方法吗?关键字'item'不工作,谢谢你的回复,现在我可以得到值。但是我想要文本,即国家name@hakkeem,使用选定值的选定项。
 protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
    {
    //I want to access the dropdown value here//
    }
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
DropDownList ddlCountries = (ListView.EditItem.FindControl("ddlcountry") as DropDownList);
if(ddlCountries!=null)
 {
string value=ddlCountries.SelectedValue;
}
}