62,046
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script language="C#" runat="server">
void SubmitBtn_Click(Object sender, EventArgs e) {
// Rather than explictly pulling out the variable from the StateList control
// and then manipulating a Label control, just call Page.DataBind.
// This will evaluate any <%# %> expressions within the page.
Page.DataBind();
}
</script>
</head>
<body>
<h3><font face="Verdana">Binding to a property of another server control</font></h3>
<form runat="server">
<asp:DropDownList id="StateList" runat="server">
<asp:ListItem>CA</asp:ListItem>
<asp:ListItem>IN</asp:ListItem>
<asp:ListItem>KS</asp:ListItem>
<asp:ListItem>MD</asp:ListItem>
<asp:ListItem>MI</asp:ListItem>
<asp:ListItem>OR</asp:ListItem>
<asp:ListItem>TN</asp:ListItem>
<asp:ListItem>UT</asp:ListItem>
</asp:DropDownList>
<asp:button Text="Submit" OnClick="SubmitBtn_Click" runat="server"/>
<p>
Selected State: <asp:label text='<%# StateList.SelectedItem.Text %>' runat="server"/>
</form>
</body>
</html>