c#中dropdownlist二级联动问题,求大神指点啊,急啊
从网上搜了个dropdownlist二级联动,然后自己删减了下,把自己要的留下来,程序很OK。
现在想嵌套入自己的另外个网页,将其中两个dropdownlist设置成联动的,也就是 省-->市,选择省,会跳出相应的市。
显示错误,_default,成员名称不能与他们的封闭类型相同。
我知道是有 两个 public partial class _Default,但是我想把两个拼接起来,如何搞啊,就是又链接服务器又能实现二级联动功能,下面附上代码。
如何调整下啊
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySQLDriverCS;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
public MySQLConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
conn = new MySQLConnection(new MySQLConnectionString("127.0.0.1", "test", "root", "1234").AsString);
conn.Open();
if (!IsPostBack)
{
BindUser();
}
}
public partial class _Default: System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
string str = Page.ClientScript.GetCallbackEventReference(this, "arg", "test", null, false);///获取一个对客户端函数的引用
string script = "function callserver(arg){" + str + "}";///组织一个callserver函数
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "key", script, true);///注册客户端脚本
DropDownList5.Attributes.Add("onchange", "callserver(document.getElementById('DropDownList5').value)");///为DropDownList5添加客户端的onchange事件,触发callserver函数
}
#region ICallbackEventHandler
string selecttext = null;
public string GetCallbackResult()
{
StringBuilder sb = new StringBuilder();
if (selecttext == "Beijing")
{
sb.Append("Beijing");
}
else if (selecttext == "Shanghai")
{
sb.Append("Shanghai");
}
else if (selecttext == "Shaanxi")
{
sb.Append("Xian,Xianyang,Ankang,Hanzhong,Yanan,Weinan,Tongchuan,Yulin,Shangluo");
}
return sb.ToString();///给客户端函数test返回一个参数sb
}
public void RaiseCallbackEvent(string eventArgument)
{
selecttext = eventArgument;///获得客户端提交的参数赋给变量selecttext
}
#endregion
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string strFullname = txtFullname.Text;
string strShortname = txtShortname.Text;
string strAddress = txtAddress.Text;
string strCode = txtCode.Text;
string strperson = txtperson.Text;
string strDept = txtDept.Text;
string strPosition = txtPosition.Text;
string strTel = txtTel.Text;
string strFax = txtFax.Text;
string strPhone = txtPhone.Text;
string strMail = txtMail.Text;
string strWeb = txtWeb.Text;
string strReason = txtReason.Text;
string strdropdownlist1 = DropDownList1.Text;
string strdropdownlist2 = DropDownList2.Text;
string strdropdownlist3 = DropDownList3.Text;
string strdropdownlist4 = DropDownList4.Text;
string strdropdownlist5 = DropDownList5.Text;
string strdropdownlist6 = DropDownList6.Text;
new MySQLInsertCommand(conn, new object[,] { { "CompanyFullname", strFullname }, { "CompanyShortname", strShortname }, { "Industry", strdropdownlist1 }, { "Type", strdropdownlist2 }, { "Set_up_time", strdropdownlist3 }, { "Person", strdropdownlist4 }, { "Province", strdropdownlist5 }, { "District", strdropdownlist6 }, { "Address", strAddress }, { "Code", strCode }, { "Contact", strperson }, { "Dept", strDept }, { "Position", strPosition }, { "Telephone", strTel }, { "Fax", strFax }, { "Mobile_phone", strPhone }, { "Email", strMail }, { "Website", strWeb }, { "System_application", strAddress }, { "Reason", strReason }, { "Date", DateTime.Now.ToString() } }, "User_message");
BindUser();
}
public void BindUser()
{
DataTable dt = new MySQLSelectCommand(conn, new string[] { "CompanyFullname", "CompanyShortname", "Industry", "Address", "Code", "Contact", "Dept", "Position", "Telephone", "Fax", "Mobile_phone", "Email", "Website", "Date" }, new string[] { "User_message" }, null, null, null).Table;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
}
protected void 用户协议_Click(object sender, EventArgs e)
{
Response.Write(" <script> window.open( 'http://www.hr-channel.com '); </script> ");
}
}