asp.net 下拉框 DropDownlist编程问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 19:18:00
有 数据表test
ID 姓名 年龄 籍贯
1 QQQ 222 上海
2 WWW 22 北京
3 EEE 11 浙江

aspx页面上 控件 一个 DropDownlist;二个 TextBox

问题:
想将表test 的“姓名”列 绑定到DropDownlist 当选定DropDownlist的值时, 对应的“年龄”,“籍贯”值返回到 二个 TextBox。

请问 这个怎么做好? 请用C#做

万分感谢赐教

<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server"

AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
</form>
</body>
===============

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.DropDownList1.DataSource = //从数据库区的dataSet
this.DropDownList1.DataTextField = "姓名";
this.DropDownList1.DataValueField = "籍贯";
this.DropDownList1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)