我在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>
我的aspx.cs
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
//I want to access the dropdown value here//
}
答案 0 :(得分:0)
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
DropDownList ddlCountries = (ListView.EditItem.FindControl("ddlcountry") as DropDownList);
if(ddlCountries!=null)
{
string value=ddlCountries.SelectedValue;
}
}