我用了4个dropdownlist,4级联动,动态绑定上去的。
当选择后要把跟这4个dropdownlist相关的内容查询并显示出来,但是SelectedIndexChanged事件
无法触发,我在网上也搜索了很多这方面的问题都无法解决,但是我自己只用1个dropdownlist试了
下,发现只用一个dropdownlist时可以触发事件,但是用4级联动后就无法触发事件了。
请大家帮帮忙,看下是什么情况造成的,我的事件是在dropdownlist的属性,然后选择
SelectedIndexChanged双击的,并且也设置了AutoPostBack="True" ,事件里也加
了if(!page.ispostback)。
当选择后要把跟这4个dropdownlist相关的内容查询并显示出来,但是SelectedIndexChanged事件
无法触发,我在网上也搜索了很多这方面的问题都无法解决,但是我自己只用1个dropdownlist试了
下,发现只用一个dropdownlist时可以触发事件,但是用4级联动后就无法触发事件了。
请大家帮帮忙,看下是什么情况造成的,我的事件是在dropdownlist的属性,然后选择
SelectedIndexChanged双击的,并且也设置了AutoPostBack="True" ,事件里也加
了if(!page.ispostback)。
解决方案 »
- 搜索相关的文字 在线等.....
- Method not found: 'System.Decimal model.products.get_p_price()'.
- Ajax中一个困扰了很久,急解决的问题.
- 请教关于FreeTextBox3.0的问题
- 请教!!
- 问一个关于数据库方面的问题
- 浏览器 打开pdf
- 今天没有办法解决了吗?
- [50分]求用split如何把一串用回车隔开的字符串添加到一个数组中
- 创建asp.net mvc4 出现错误,请问该如何解决?
- windows 2008 Standard Server /visual studio 2008/Crystal Report 2008兼容性问题
- asp.net怎么实现套打
<asp:ListItem Selected="True">请选择产地</asp:ListItem>
<asp:ListItem>国产汽车</asp:ListItem>
<asp:ListItem>进口汽车</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" Width="120px" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="chinese" DataValueField="chinese">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:521che_comConnectionString %>"
SelectCommand="SELECT [chinese], [chandi] FROM [t_cars_brand] WHERE ([chandi] = @chandi)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="null" Name="chandi"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList3" Width="120px" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource2" DataTextField="cartype" DataValueField="cartype">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:521che_comConnectionString %>"
SelectCommand="SELECT [pinpai], [chandi], [cartype] FROM [t_cars_type] WHERE (([pinpai] = @pinpai) AND ([chandi] = @chandi))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="pinpai" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="chandi" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList4" Width="120px" runat="server" DataSourceID="SqlDataSource3"
DataTextField="subtype" DataValueField="subtype" AutoPostBack="True" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:521che_comConnectionString %>"
SelectCommand="SELECT [subtype], [xilie] FROM [t_cars_subtype] WHERE (([xilie] = @xilie) AND ([chandi] = @chandi) AND ([pinpai] = @pinpai))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="xilie" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="chandi" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList2" Name="pinpai" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (this.DropDownList1.SelectedValue == "请选择产地")
{
pic = "car/images/selectModel_blank.gif"; }
else
{
string sql = "select * from t_newcar where pinpai='" + this.DropDownList2.SelectedValue + "' and xilie='" + this.DropDownList3.SelectedValue + "' and chexing='" + this.DropDownList4.SelectedValue + "'";
DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sql);
DataTable dt = ds.Tables[0];
pinpai = dt.Rows[0]["pinpai"].ToString();
chexing = dt.Rows[0]["chexing"].ToString();
leixing = dt.Rows[0]["newcar_type"].ToString();
changshang = dt.Rows[0]["newcar_factory"].ToString();
year = dt.Rows[0]["newcar_year"].ToString();
pic = "img/cars_image/";
pic += dt.Rows[0]["newcar_image"].ToString();
price = dt.Rows[0]["clear_price"].ToString();
}
}
}
有是数据源绑定,又是后台DataSource赋值,我看的有点晕!!
单步调试才是解决问题的王道。
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.DataBind();
DropDownList3.DataBind();
DropDownList4.DataBind();
} protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.DataBind();
DropDownList4.DataBind();
} protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList4.DataBind();
}不太明白你在DropDownList4_SelectedIndexChanged的代码
既然用SqlDataSource为什么还用传统的.