错误 1 非静态的字段、方法或属性“System.Web.UI.WebControls.ListControl.SelectedItem.get”要求对象引用
这是怎么回事啊,各位大侠帮帮忙啊,代码:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<script runat="server">
protected void SubmitBtn_Click(object sender, EventArgs e)
{
Label1.Text = "您的选择的城市是:<font color=red>" +
DropDownList.SelectedItem.Text + "<br></font>";
}
</script>
<html xmlns="http://www. >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong><span style="font-size: 16pt">DropDownList示例</span></strong><br />
<hr />
</div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="102px">
<asp:ListItem>北京</asp:ListItem>
<asp:ListItem>上海</asp:ListItem>
<asp:ListItem>广州</asp:ListItem>
<asp:ListItem>长沙</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="SubmitBtn_Click" Text="选择" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>