我在.net中有這個奇怪的gridview問題,至今我還沒有找到可以解決的問題。 這是什麼關於: 我有一個由sqldatareader使用的存儲過程。 然後我有閱讀器讀取所有值並從存儲過程中顯示。 問題現在正在發生。當我輸入參數的某些特定值時,所有內容都可以在屏幕上呈現出來。例如,我有日期和最小/最大量,並且gridview正確填充。 當我包括一個參數,可以說客戶電子郵件,讀者說,這是有行,但在GridView保持空白:asp.net中的奇怪gridview問題
SqlDataReader rdrAdvancedReport = commAdvanced.ExecuteReader();
while (rdrAdvancedReport.Read())
{
gvResults.DataSource = rdrAdvancedReport;
gvResults.DataBind();
}
rdrAdvancedReport.Close();
更重要的是「有趣」的是,我有另外一個循環一次在GridView循環完成,給我所有訂單的總金額,並且標籤填寫正確。
if (rdrTotal.HasRows)
{
while (rdrTotal.Read())
{
orderTotalSum = orderTotalSum + Convert.ToDouble(rdrTotal["OrderTotal"]);
任何想法傢伙什麼可以是問題?
這裏是存儲過程太:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE SearchCust
(
@StartTime datetime = null,
@EndTime datetime = null,
@CustomerEmail nvarchar(255) = null,
@Username nvarchar(255) = null,
@CustomerName nvarchar(255) = null,
@MinimumOrderAmount decimal = null,
@MaximumOrderAmount decimal = null,
)
AS
BEGIN
SET NOCOUNT ON
SELECT DISTINCT o.OrderID, o.OrderTotal, o.ShippingCountry, n.Name AS OrderStatus, p.Name AS PaymentStatus FROM Order o
JOIN OrderStatus n ON o.OrderStatusID = n.OrderStatusID
JOIN PaymentStatus p ON o.OrderStatusID = p.PaymentStatusID
JOIN Customer c ON o.CustomerID = c.CustomerID
JOIN OrderProduct op ON o.OrderID = op.OrderID
JOIN ProductValue pv ON op.ProductVariantID = pv.ProductVariantId
WHERE (o.CreatedOn > @StartTime OR @StartTime IS NULL)
AND (o.CreatedOn < @EndTime OR @EndTime IS NULL)
AND (o.ShippingEmail = @CustomerEmail OR @CustomerEmail IS NULL)
AND (c.Username = @Username OR @Username IS NULL)
AND (o.BillingFirstName + ' ' + o.BillingLastName = @CustomerName OR @CustomerName IS NULL)
AND (o.ShippingFirstName + ' ' + o.ShippingLastName = @CustomerName OR @CustomerName IS NULL)
AND (o.OrderTotal > @MinimumOrderAmount or @MinimumOrderAmount IS NULL)
AND (o.OrderTotal < @MaximumOrderAmount OR @MaximumOrderAmount IS NULL)
ORDER BY o.OrderID
END
在此先感謝
thx man,you made my day ! – Laziale 2010-11-01 12:41:28