Hi! Thanks for aswering.
The code is good, you are right. I saw another code from Michael Washington on the web where he uses the 2 parameters just putting them there, separated by commas: Using dr As IDataReader = DotNetNuke.Data.DataProvider.Instance().ExecuteReader("GetSurvey", SurveyID, ModuleId).
The error I get is that the set of records is always empty. Despite the text I put in the textbox I'm using in the ascx to be the "filter". Even leaving it empty.
I have this StoredProcedure for retrieving the records that will fill the GridView:
ALTER PROCEDURE [dbo].[D4010_ThingsForSale_SelectAll]
@ModuleId int, @Description varchar(250)
AS
SELECT ID, ModuleId, UserID, Category, Description, Price
FROM D4010_ThingsForSale
WHERE (ModuleId = @ModuleId) AND (Description LIKE '%@Description%')
ORDER BY Category
In the ascx I have this Textbox1, DataSource and GridView:
<span class="style1">Description contains: </span> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Buscar" /><br />
<asp:ObjectDataSource ID="ObjectDataSource_ThingsForSale" runat="server" DataObjectTypeName="YourCompany.Modules.ThingsForSale.ThingsForSaleInfo" DeleteMethod="ThingsForSale_Delete" InsertMethod="ThingsForSale_Insert" OldValuesParameterformatString="original_{0}" OnInit="Page_Load" SelectMethod="ThingsForSale_SelectAll" TypeName="YourCompany.Modules.ThingsForSale.ThingsForSaleController" UpdateMethod="ThingsForSale_Update"> <SelectParameters> <asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" /> <asp:ControlParameter ControlID="TextBox1" DefaultValue="" Name="Description" PropertyName="Text" Type="String" /></SelectParameters> </asp:ObjectDataSource> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="ObjectDataSource_ThingsForSale" DataKeyNames="ID,UserID,ModuleId" CellPadding="4" CellSpacing="1" Enableview_state="False"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowSelectButton="True" /> <asp:BoundField DataField="ModuleId" HeaderText="ModuleId" SortExpression="ModuleId" Visible="False" /> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="False" /> <asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" Visible="False" /> <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /> </Columns> <EmptyDataTemplate> There are no Things 4 Sale </EmptyDataTemplate> </asp:GridView>
I've tesed the thing putting the Description LIKE '%%' (empty string) in the Stored Procedure and it returns the complete set of records. So, the problem appears to be that I'm not being able to send the Textbox1.Text value to the Stored Procedure.
And this DataObject method:
<DataObjectMethod(DataObjectMethodType.Select)> _
PublicSharedFunction ThingsForSale_SelectAll(ByVal ModuleId As Integer, ByVal Description As String) As List(Of ThingsForSaleInfo)
Return CBO.FillCollection(Of ThingsForSaleInfo)(CType(DataProvider.Instance().ExecuteReader("ThingsForSale_SelectAll", ModuleId, Description), IDataReader))
End Function