我遇到了一个小问题,并希望有人能够提供帮助。我正在使用一个面板 - 在页面加载时,它应该列出所有产品,因为没有根据存储过程选择任何类别(这完美地工作)。
当用户点击特定类别时,它应该只显示具有特定CategoryID
的产品。当我在SQL中运行代码时,它也是这个部分的梦想,所以假设存储过程没问题。
CategoryID = CategoryID
在GetProducts
中,我得到了
警告:对同一变量进行分配;你的意思是分配其他东西吗?
但是我正在关注教程视频,这很好用。还有另一个愚蠢的错误阻止它工作吗?
我想我已经包含了所有必需的代码 - 抱歉,如果它有点矫枉过正!!
提前谢谢 - 杰克
代码pnlCategories
背后的代码:
private void GetProducts(int CategoryID)
{
ShoppingCart k = new ShoppingCart();
{
CategoryID = CategoryID;
};
答案 0 :(得分:1)
发现错误 - 附加“;”在以下行添加:
DistortionMesh
代码现在读取
ShoppingCart k = new ShoppingCart();
并按预期运作!
答案 1 :(得分:0)
看起来像是一个c#错误而不是SQL Server错误。
问题出在您的GetProducts方法中。 // read file as string and turn into an array, 1 element per line
$records = explode("\n", file_get_contents('path/to/file'));
// turn each line into an array, 1 element per field
array_walk($records, function (&$record) { $record = explode('|', $record); });
//$records is now a two-dimensional array containing the data
// gather the prices into a new array
$prices = array_map(function ($record) { return (int) $record[2]; }, $records);
// use the prices to sort the records
array_multisort($prices, SORT_ASC, $records);
foreach ($records as $record) {
//... do your thing.
}
C#区分大小写。如果仔细检查教程,其中一个可能是小写的。确保您仔细输入。 尝试下面的代码更改,看看编译器抱怨的位置。 CategoryID = categoryID;
CategoryID = CategoryID;