嗨,当我从下拉列表中选择“其他”时,我想将我的文本框和按钮可见性设置为true。我该怎么做?
我的代码隐藏
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Visible = false;
Button1.Visible = false;
TextBox2.Visible = false;
Button2.Visible = false;
if (!IsPostBack)
{
PopulateDDLFromXMLFile();
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "Others")
{
TextBox1.Visible = true;
Button1.Visible = true;
}
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
if (DropDownList2.SelectedValue == "Others")
{
TextBox2.Visible = true;
Button2.Visible = true;
}
}
protected void XmlDataSource1_Transforming(object sender, EventArgs e)
{
}
protected void TextBox3_TextChanged1(object sender, EventArgs e)
{
}
public void PopulateDDLFromXMLFile()
{
DataSet ds = new DataSet();
ds.ReadXml(MapPath("~/App_Data/builderemail.xml"));
//get the dataview of table "Country", which is default table name
DataView dv = ds.Tables["builder"].DefaultView;
DataView dw = ds.Tables["manager"].DefaultView;
//or we can use:
//DataView dv = ds.Tables[0].DefaultView;
//Now sort the DataView vy column name "Name"
dv.Sort = "value";
//now define datatext field and datavalue field of dropdownlist
DropDownList1.DataTextField = "value";
DropDownList1.DataValueField = "ID";
DropDownList2.DataTextField = "value";
DropDownList2.DataValueField = "ID";
//now bind the dropdownlist to the dataview
DropDownList1.DataSource = dv;
DropDownList1.DataBind();
DropDownList2.DataSource = dw;
DropDownList2.DataBind();
}
}
我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<email>
<builderemail>
<builder>
<id>1</id>
<value>builder@xyz.com</value>
</builder>
<builder>
<id>2</id>
<value>Others</value>
</builder>
</builderemail>
<manageremail>
<manager>
<id>1</id>
<value>manager@xyz.com</value>
</manager>
<manager>
<id>2</id>
<value>Others</value>
</manager>
</manageremail>
</email>