我正在尝试ALL
为我的 aspx 页面添加搜索功能。问题是我不知道如何正确地做到这一点。这是我能做到的,这是背后的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dtTransactionCategory = clsTransactionCategory.GetTransactionCategory(Helper.LogID, Helper.OrgID, Helper.SiteID, 0, string.Empty);
ddlTransactionCategoryDesc.DataSource = dtTransactionCategory;
ddlTransactionCategoryDesc.DataTextField = "TransactionCategoryDesc";
ddlTransactionCategoryDesc.DataValueField = "TransactionCategoryID";
ddlTransactionCategoryDesc.DataBind();
ddlTransactionCategoryDesc.Items.Insert(0, new ListItem("All"));
ddlTransactionCategoryInput.DataSource = dtTransactionCategory;
ddlTransactionCategoryInput.DataTextField = "TransactionCategoryDesc";
ddlTransactionCategoryInput.DataValueField = "TransactionCategoryID";
ddlTransactionCategoryInput.DataBind();
logID = CommonFunctions.StringToInt(Session[Constants.SessionLogID].ToString());
orgID = 1;
siteID = 1;
ddlTransactionCategoryDesc.SelectedValue = Convert.ToString(ddlTransactionCategoryDesc);
txtTransactionDesc.Text = string.Empty;
BindData();
}
}
和存储过程,如果它需要:
ALTER PROC [dbo].[spMSTransaction_Get]
@OrgID INT,
@SiteID INT,
@TransactionCategoryID INT,
@TransactionCategoryDesc varchar (300),
@TransactionDesc varchar(300)
AS
SET NOCOUNT ON
SELECT mst.[OrgID],
mst.[SiteID],
mst.[TransactionID],
mst.[TransactionCategoryID],
mstc.[TransactionCategoryDesc],
mst.[TransactionDesc],
mst.[IsActive],
[master].dbo.fnConvertUTCToLocalTimeZone (mst.[CreatedDate]) as [CreatedDate],
mst.[CreatedBy],
[master].dbo.fnConvertUTCToLocalTimeZone (mst.[ModifiedDate]) as [ModifiedDate],
mst.[ModifiedBy]
FROM [dbo].[MSTransaction] AS mst
INNER JOIN [dbo].[MSTransactionCategory] AS mstc
ON mst.OrgID = mstc.OrgID AND mst.SiteID = mstc.SiteID AND mst.TransactionCategoryID = mstc.TransactionCategoryID
WHERE (mst.[OrgID] = @OrgID OR @OrgID = 0)
AND (mst.[SiteID] = @SiteID OR @SiteID = 0)
AND (mst.[TransactionCategoryID] = @TransactionCategoryID OR @TransactionCategoryID = 0)
AND (mst.[TransactionDesc] LIKE '%' + @TransactionDesc + '%')
AND (mst.[isActive] = 1)
我已经放了ddlTransactionCategoryDesc.Items.Insert(0, new ListItem("All"));
,但它返回了一个错误:
输入字符串的格式不正确。
知道我需要修复什么以及应该做些什么来实现ALL
搜索功能吗?谢谢。