在ComboBox的SelectedIndexChanged事件里操作
解决方案 »
- Linq中的OrderBy哪错了?
- WINFORM窗体tab键的问题
- 问题? 如何在Access文件中用sql 语句创建数据表?在线等..
- DataRow row = AuthorData.authors[e.Item.DataSetIndex] 这句话的理解
- 动态创建的控件的OcxState属性怎么设置?
- DataGridView的BUG,欢迎讨论。
- 请问有上海微创的GGJJ在么,请教个问题
- vs中c#做网页imageButton按钮的HotSpots属性设置
- 高分求救
- 帮帮忙,我有administrator口令,如何拿回文件?在线等回复。
- 求救,WebServce中使用了自定义序列化,测试结果没有输出
- C#怎么利用Chart控件绘制极坐标图
protected void Button1_Click(object sender, EventArgs e)
{
this.Label1.DataBind();
}
</script><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<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="Button1_Click" Text="提交" />
<br />
<br />
你选择的是:<asp:Label ID="Label1" runat="server" Text="<%# DropDownList1.Text %>"></asp:Label>
</div>
</form>
</body>
</html>
<TextBox Name="tb" Width="140" Height="30"></TextBox>
<ListBox Name="lb" Width="100" Height="55" SelectionChanged="PrintText" SelectionMode="Single">
<ListBoxItem>Item 1</ListBoxItem>
<ListBoxItem>Item 2</ListBoxItem>
<ListBoxItem>Item 3</ListBoxItem>
<ListBoxItem>Item 4</ListBoxItem>
<ListBoxItem>Item 5</ListBoxItem>
<ListBoxItem>Item 6</ListBoxItem>
<ListBoxItem>Item 7</ListBoxItem>
<ListBoxItem>Item 8</ListBoxItem>
<ListBoxItem>Item 9</ListBoxItem>
<ListBoxItem>Item 10</ListBoxItem>
</ListBox>
void PrintText(object sender, SelectionChangedEventArgs args)
{
ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
tb.Text = " You selected " + lbi.Content.ToString() + ".";
}
Private Sub PrintText(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Dim lbsender As ListBox
Dim li As ListBoxItem lbsender = CType(sender, ListBox)
li = CType(lbsender.SelectedItem, ListBoxItem)
tb.Text = " You selected " & li.Content.ToString & "."
End Sub
C# 复制代码
void PrintText(object sender, SelectionChangedEventArgs args)
{
ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
tb.Text = " You selected " + lbi.Content.ToString() + ".";
}