1、用数据库绑定的插入首行的问题
后台代码:
private void DownBind1()
{
//默认显示分类号为1的所有子类
string dda = "";
if (Session["u_qy"].ToString() == "1")
{
dda = "select * from tbType where u_qy='1' order by u_team";
}
else if (Session["u_qy"].ToString() == "2")
{
dda = "select * from tbType where u_qy='2' order by u_team";
}
DataTable mytab = this.Get_Dt2(dda);
this.DropDownList1.DataSource = mytab;
this.DropDownList1.DataValueField = "u_team";
this.DropDownList1.DataTextField = "u_team";
this.DropDownList1.DataBind();
//添加一个"请选择"行
this.DropDownList1.Items.Insert(0, new ListItem("请选择分类", ""));
}
提示错误信息:
编译器错误消息: CS1502: 与“System.Collections.ObjectModel.Collection<ExtAspNet.ListItem>.Insert(int, ExtAspNet.ListItem)”最匹配的重载方法具有一些无效参数
不知道为什么不行,但官方示例那个省市联动是可以的。请求答案。
2、绑定DropDownList1之后,要利用DropDownList1_SelectedIndexChanged事件联动DropDownList2,也是根据数据库绑定的。但不行,弹出框框提示 Internal Error(500),且提示未将对象实例化。
后台代码:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem != null)
{
string dda = "";
if (Session["u_qy"].ToString() == "1")
{
if (Session["u_jn"].ToString() == "四区动感")
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='四区动感' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
}
else if (Session["u_jn"].ToString() == "四区神")
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='四区神' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
}
else if (Session["u_jn"].ToString() == "江湛动神" || Session["u_jn"].ToString() == "江湛神")
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and (u_jn='江湛动神' or u_jn='江湛神') and u_name!='" + Session["u_name"].ToString() + "' order by u_name";
}
else
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='" + Session["u_jn"] + "' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
}
}
else if (Session["u_qy"].ToString() == "2")
{
string aaaa = Session["u_jn"].ToString();
if (Session["u_jn"].ToString() == "复合全球通")
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='复合全球通' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
}
else if (Session["u_jn"].ToString() == "四区全球通")
{
dda = "select * from OT_user_table where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='四区全球通' and u_name!='" + Session["u_name"].ToString() + "' order by u_team,u_jn ";
}
else
{
dda = "select * from OT_user_table where u_zg='2' and (u_qy='1' or u_qy='2') and u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='" + Session["jn"] + "' and u_name!='" + Session["u_name"].ToString() + "' order by u_team,u_jn ";
}
}
this.DropDownList2.DataSource = Get_Dt(dda);
this.DropDownList2.DataValueField = "u_Labor_number";
this.DropDownList2.DataTextField = "u_name";
this.DropDownList2.DataBind();
//this.ddlMsg.Items.Insert(0, new ListItem("=请选择姓名=", "0"));
}
}
请求各位高手解决我的传值问题。本人菜鸟,初学者!
|