2010-07-26 80 views
1

我在这个下面的代码的应用程序有一个TextBox1和搜索按钮:我怎样才能重定向基于选择一个DropDownList的

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Response.Redirect("~\\searchpage.aspx?PatientNRIC=" + TextBox1.Text); 
} 

这意味着,如果用户键入只IC NO:S1234567D,那么当点击它会显示患者详细视图。

所以我现在做的事情差不多,但现在我有TextBox2DropDownList1。在DropDownList1里面,我有“Name”,“IC No”,“Test_Date”。例如,我在文本框1中键入“S1234567D”,然后在DropDownList1中选择“IC No”,它应该将我重定向到S1234567D的患者详细视图的页面。

我该怎么做我的代码?谢谢!

回答

0

像下面的内容可能会为你工作:

protected void Button1_Click(object sender, EventArgs e) 
{ 
    if(dropdownlist1.SelectedValue == "IC No") 
    { 
     // assuming this is the redirect to your patients details view 
     // but you MUST use only forward slashes to make it work (!) 
     Response.Redirect("~/searchpage.aspx?PatientNRIC=" + TextBox1.Text); 
    } 
} 
0
name.Text = ddl1.DataTextField; 
    ICNo.Text = ddl1.DataValueField; 
    textBox1.Text = name.text+ICno.Text; 

保护无效的button1_Click(对象发件人,EventArgs的) {

如果(TextBox1的!= NULL) { 响应.Redirect(“〜/ searchpage.aspx?PatientNRIC =”+ TextBox1.Text); } } }

相关问题