list box 2 show items according 2 current variable
Hi I need some christmas help please.
I would like my drop down list box to show all items according to a certain foreign key field. The drop down list come's from a table tblSalesItemsCostNotes. The list box is currently displaying all records in this table, but I would like it to display according to the parameter field intSalesItemTypeID.
The tblSalesItemsCostNotes table is structured as follows.
intCostNotesID (PK)
intSalesItemTypeID - parameter I would like to use.
strCostNotes - value(s) that must be displayed in the list box
My stored procedure is as follows and think should be fine.
-------
CREATE PROCEDURE [dbo].[tblSalesItemType_ListBySalesItemTypeID]
(
@intSalesItemTypeID int
)
AS
SELECT
*
FROM
tblSalesItemCostnotes
INNER JOIN
tblSalesItemType ON tblSalesItemType.intSalesItemTypeID = tblSalesItemCostnotes.intSalesItemTypeID
WHERE
tblSalesItemCostnotes.intSalesItemTypeID = @intSalesItemTypeID
GO
------
This is my code for the drop down list in file SaleItemEdit.ascx
------
XXX.BLL.TblSalesItemTypeList costnotes = new XXX.BLL.TblSalesItemTypeList();
this.DropDownSaleItemCostNotes.Items.Clear();
this.DropDownSaleItemCostNotes.Items.Add(new ListItem("",""));
reader = types.GetDataReaderBySalesItemTypeID();
while (reader.Read())
{
this.DropDownSaleItemCostNotes.Items.Add(new ListItem(reader["strCostNotes"].ToString(), reader["intCostNotesID"].ToString()));
}
reader.Close();
-----
code in BLL file TblSalesItemTypeList.cs
-----
public IDataReader GetDataReaderBySalesItemTypeID(int intSalesItemTypeID)
{
return dal.GetDataReaderBySalesItemTypeID((int)intSalesIt emTypeID);
}
-----
Code in DAL - TabletblSalesItemType.cs
-----
public IDataReader GetDataReaderBySalesItemTypeID(params object[] parameterValues)
{
return DataModifier.GetDataReader(this.tableName + "_ListBySalesItemTypeID", parameterValues);
}
----
I hope this is not too confusing. Apologees as I am fairly new to ASP.net
thanks in advance
|