本文介绍了在ASP.NET C#中未触发onselectedindexchanged下拉列表事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上在我的项目中添加了一个下拉列表,然后只是激发了onselectedindexchanged上的事件,我尝试了很多东西来解雇它,

最后我把它绑起来真的不行,请帮帮我..还有一个我在项目中也添加了一个模板。关于那个模板有什么问题吗?



我尝试了什么:



这里是我的代码:

< asp:DropDownList ID =drl1runat =serverOnSelectedIndexChanged =drl1_SelectedIndexChanged>



代码:

if(!IsPostBack)

{

ShowDDL();

}



private void ShowDDL()

{

var size =来自PS的drop.Product_Size

选择新的{PS.Size,PS.Size_Id};

drl1.DataValueField =Size_Id;

drl1.DataTextField =Size;

drl1.DataSource = size.ToList();

drl1.DataBind();

drl1.Items.Insert(0, - 选择大小 - );

}





试试

{

string size = drl1.Selected价值;

var products =(来自PM in drop.PRODUCT_DBM

加入PS in drop.Product_Size on PM.product_size_id等于PS.Size_Id

其中PS.Size == size

选择新的

{

PS.Size

});

}

catch(例外情况)

{

}

解决方案

I actually added one dropdownlist in my project and then just fired event onselectedindexchanged and i tried a lot to fire it,
at last i tied its really not working please help me.. and one more thing i have added one template also in my project. is there any problem regarding that template?

What I have tried:

here is my code:
<asp:DropDownList ID="drl1" runat="server" OnSelectedIndexChanged="drl1_SelectedIndexChanged" >

CODE:
if (!IsPostBack)
{
ShowDDL();
}

private void ShowDDL()
{
var size = from PS in drop.Product_Size
select new { PS.Size, PS.Size_Id };
drl1.DataValueField = "Size_Id";
drl1.DataTextField = "Size";
drl1.DataSource = size.ToList();
drl1.DataBind();
drl1.Items.Insert(0, "-Select Size-");
}


try
{
string size = drl1.SelectedValue;
var products = (from PM in drop.PRODUCT_DBM
join PS in drop.Product_Size on PM.product_size_id equals PS.Size_Id
where PS.Size == size
select new
{
PS.Size
});
}
catch (Exception ex)
{
}

解决方案


这篇关于在ASP.NET C#中未触发onselectedindexchanged下拉列表事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:11