如何更改一个下拉列表中的值会更改,具体取决于aspx中另一个下拉列表中的值

时间:2013-04-02 17:10:48

标签: asp.net vb.net sql-server-2008

我在aspx页面中有两个下拉框。一个用于位置,一个用于供应商列表。 我从这个

的位置下拉列表中获取值
 SELECT Location_ID LocationID, Location_Name LocationDesc, BusinessID
 FROM inventory.tbl_location
union 
SELECT '' LocationID,'select a location' LocationDesc,0 BusinessID
ORDER BY BusinessID,Location_Name

我可以从中获取供应商下拉列表中的所有记录列表:

SELECT p.PayeeID, isnull(Name1_Last,'') + ',  ' + isnull(Name1_First,'') VendorName, b.BusinessID
from tblVendor_Payees p join tblVendor_Business b 
on p.PayeeID=b.PayeeID 
where VendorType=1
order by isnull(Name1_Last,'') + ',  ' + isnull(Name1_First,'')

我想根据位置下拉列表仅列出那些供应商记录。怎么做?。

1 个答案:

答案 0 :(得分:0)

您可以设置一个下拉列表,该列表是绑定到单独的select语句的数据,以获取供应商类型。

您的查询看起来像这样

 SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "
SELECT p.PayeeID, isnull(Name1_Last,'') + ',  ' + isnull(Name1_First,'') VendorName, b.BusinessID
from tblVendor_Payees p join tblVendor_Business b 
on p.PayeeID=b.PayeeID 
where VendorType= @vender 
order by isnull(Name1_Last,'') + ',  ' + isnull(Name1_First,'') "

cmd.Parameters.Add("@vender", SqlDbType.VarChar).Value = drop_down_list_vendor .Text;

然后,您需要做的就是构建用户从中选择供应商的下拉列表。