上面那个错误我已经解决了。我实现的是两个DropDownList的二级关联,现在数据都关联上去了,但第二个DropDownList不能实现动态联动,我怎么也看不出来是代码的那个地方有问题,请大家帮我看看:
<script language="C#" runat=server>private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!IsPostBack)
{
SqlConnection conn = new SqlConnection("server=systemserver;database=RtsCase;user id=sa;pwd=systemserver");
conn.Open();
DataSet ds = new DataSet();
try
{
String strSQL="select * from specialtyTab ";
SqlDataAdapter objAdapter=new SqlDataAdapter(strSQL, conn);
objAdapter.Fill(ds,"AccountGp");
AccountGroup.DataSource=ds.Tables["AccountGp"].DefaultView;
AccountGroup.DataTextField = "specialtyName";
AccountGroup.DataValueField = "specialtyNum";
AccountGroup.DataBind(); //绑定组列表 ;
}
catch{}
BindAccount(ds,conn);
}
}protected void AccountGroup_SelectedIndexChanged(object sender, System.EventArgs e)
{
string strConnection = ConfigurationSettings.AppSettings["SQLConnectionString"];
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
DataSet ds = new DataSet();
BindAccount(ds,conn);
}private void BindAccount(DataSet dss,SqlConnection connn)
{
try
{
String strSQL1="select deviceSystemName from deviceSystemTab where fromSpecialtyNum='"+AccountGroup.SelectedItem .Value+"'";
SqlDataAdapter objAdapter1=new SqlDataAdapter(strSQL1, connn);
objAdapter1.Fill(dss,"CurAccount");
CurAccount.DataSource=dss.Tables["CurAccount"].DefaultView;
CurAccount.DataTextField = "deviceSystemName";
CurAccount.DataBind(); //绑定当前组成员列表;
}
catch{}
} </script> <ASP:DropDownList id=AccountGroup AutoPostBack=true SelectedIndexChanged="AccountGroup_SelectedIndexChanged" runat=server>
</ASP:DropDownList>
<ASP:DropDownList id=CurAccount runat=server>
</ASP:DropDownList>
<script language="C#" runat=server>private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!IsPostBack)
{
SqlConnection conn = new SqlConnection("server=systemserver;database=RtsCase;user id=sa;pwd=systemserver");
conn.Open();
DataSet ds = new DataSet();
try
{
String strSQL="select * from specialtyTab ";
SqlDataAdapter objAdapter=new SqlDataAdapter(strSQL, conn);
objAdapter.Fill(ds,"AccountGp");
AccountGroup.DataSource=ds.Tables["AccountGp"].DefaultView;
AccountGroup.DataTextField = "specialtyName";
AccountGroup.DataValueField = "specialtyNum";
AccountGroup.DataBind(); //绑定组列表 ;
}
catch{}
BindAccount(ds,conn);
}
}protected void AccountGroup_SelectedIndexChanged(object sender, System.EventArgs e)
{
string strConnection = ConfigurationSettings.AppSettings["SQLConnectionString"];
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
DataSet ds = new DataSet();
BindAccount(ds,conn);
}private void BindAccount(DataSet dss,SqlConnection connn)
{
try
{
String strSQL1="select deviceSystemName from deviceSystemTab where fromSpecialtyNum='"+AccountGroup.SelectedItem .Value+"'";
SqlDataAdapter objAdapter1=new SqlDataAdapter(strSQL1, connn);
objAdapter1.Fill(dss,"CurAccount");
CurAccount.DataSource=dss.Tables["CurAccount"].DefaultView;
CurAccount.DataTextField = "deviceSystemName";
CurAccount.DataBind(); //绑定当前组成员列表;
}
catch{}
} </script> <ASP:DropDownList id=AccountGroup AutoPostBack=true SelectedIndexChanged="AccountGroup_SelectedIndexChanged" runat=server>
</ASP:DropDownList>
<ASP:DropDownList id=CurAccount runat=server>
</ASP:DropDownList>
解决方案 »
- 关于模板里DataList数据的刷新
- 在win7上部署asp.net的一个物流管理系统时遇到了写问题,求解决
- ==================强烈要求CSND换回原版=================
- 关于GridView 的动态改变邦定列的顺序。高手来,帮助解决。(很难)
- 倒大霉了,我在xst文件里插入了 msxsl:script 最终需要 客户的机器装.net 运行环境,才能执行, 天啦,完蛋了
- ASP.NET发邮件问题socket
- 验证控件怎么用啊,取消时候怎么样让他不要验证啊?
- 如何释放过期的Session所占用的内存?
- 请教水晶报表的书籍
- 无法将类型“string”隐式转换为“System.Web.UI.WebControls.ButtonColumnType”
- 希望顶级高手能进来-->用streamReader的ReadLine读中文文件时出现乱码!
- 如何用ASP.NET在客户端打开EXCEL文件
现在我的问题是不能实现动态数据联动,代码在上面,不知是什么原因?