I am not sure what I am supposed to write in the code behind for my vb.net project. I have a repeater that filters a gridview. When trying to declare the scalar variable @CompanyID, I get the error I mentioned in the title of this post. Can someone help me? I have tried to look for the answer on many forums, but I can’t find the right answer.
dsLetters.SelectCommand = "SELECT DISTINCT LEFT(ProductName, 1) AS [Letter]
FROM Product, CompanyLink, Company
WHERE Product.ProductID = CompanyLink.ProductID
AND CompanyLink.CompanyID = Company.CompanyID
AND Company.CompanyID = @CompanyID"
'declaring scalar variable @CompanyID
dsLetters.SelectParameters.Clear()
Dim cp As ControlParameter = New ControlParameter
cp.ControlID = "rptLetters"
cp.DefaultValue = "-1"
cp.Name = "CompanyID"
cp.PropertyName = "SelectedValue"
cp.Type = TypeCode.Decimal
dsLetters.SelectParameters.Add(cp)
I think the issue is that repeaters don’t have the concept of a selected value; all they do is show what you have selected. What you may need to do is mimic the repeater values in a hidden dropdownlist and add client-side code to choose the appropriate value in the dropdownlist, then bind your ControlParameter to this property.