Posted: 5/25/2011
I am displaying data in a report.
I want to filter the data in the report based on the selected value from ta dropdown menu.
This now I have done this but seems like data is not getting affected in the report and "Amount Paid" field is empty for all t he field even though there are value saved in the database for this field.
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DropDownTableAdapters.YearTableTableAdapter"> </asp:ObjectDataSource> <br /> <br /> Select Year <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="ObjectDataSource3" DataTextField="Year_Of_Payment" DataValueField="Year_Of_Payment"> </asp:DropDownList> <br /> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="11in" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="8.5in"> <LocalReport ReportPath="ReportTestDrop.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="DataSet1" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataSet2TableAdapters.DataTable1TableAdapter"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" DefaultValue="-1" Name="YearPaayment" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="DataSet2TableAdapters.DataTable1TableAdapter"> </asp:ObjectDataSource>
My ObjectDataSource3, I am using this SQL Command:
SELECT DISTINCT YearTable.Year_Of_PaymentFROM MemberTable INNER JOIN Payment_Table ON MemberTable.ID = Payment_Table.ID INNER JOIN YearTable ON Payment_Table.YearID = YearTable.YearIDORDER BY YearTable.Year_Of_Payment DESC
My ObjectDataSource2, I am using this SQL Command:
SELECT DISTINCT MemberTable.FirstName, MemberTable.LastName, MemberTable.City, MemberTable.State, Payment_Table.AmountPaidFROM MemberTable INNER JOIN Payment_Table ON MemberTable.ID = Payment_Table.ID INNER JOIN YearTable ON Payment_Table.YearID = YearTable.YearIDWHERE (YearTable.Year_Of_Payment = @YearPaayment)
PLEASE HELP
Posted: 5/26/2011
hi Jeff ,
for DropDownList1 you have mentioned autopost back true, but not mentioned onselectedinexchanged event...
and in the onselectedinexchanged you have to pass the parameter @YearPaayment to ObjectDataSource2.
Can you please show me in code how to do that ? I don't know how to pass parameter.
Here is the complete description of my report.
Here is the structure of my tables:
This is the structure of my 3 tables:
CREATE TABLE [dbo].[MemberTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](max) NULL, [LastName] [nvarchar](max) NULL, [Address] [nvarchar](max) NULL, [City] [nvarchar](max) NULL, [State] [nvarchar](max) NULL, [Zip] [nvarchar](max) NULL, [POBox] [nvarchar](max) NULL, CONSTRAINT [PK_MemberTable] PRIMARY KEY CLUSTERED ----------------------CREATE TABLE [dbo].[Payment_Table]( [PaymentID] [int] IDENTITY(1,1) NOT NULL, [ID] [int] NOT NULL, [YearID] [int] NOT NULL, [SuggestedDonation] [money] NULL, [AmountPaid] [money] NULL, [PaymentDate] [datetime] NULL, [Status] [bit] NULL, CONSTRAINT [PK_Payment_Table] PRIMARY KEY CLUSTERED ------------------CREATE TABLE [dbo].[YearTable]( [YearID] [int] IDENTITY(1,1) NOT NULL, [Year_Of_Payment] [nvarchar](50) NULL, CONSTRAINT [PK_YearTable] PRIMARY KEY CLUSTERED
I want to create a report in which I should be able display:
ID, First Name, Last Name, Address, POBox, State, City, AmountPaid
Want to add filters with 2 dropdown menus:
Filter Option Based on "Year": Choose Year (for which I want to display the report - year will be coming from database from yearTable)
Second Filter : Based on "Status" - Paid/Un-paid/All (In datbase, it will be true/false or 1 or 0)
Right now I am developing project on my local machine but database is still on the server and as soon as I am able to create this report I will transfer all the pages and reports on the server.
Please let me know if you need more information. thank you
Here's the screenshot I designed to explain what I am looking for:
1) Select Year
2) Status (Paid / Un-paid / All)
Posted: 5/27/2011
anyone ?
Posted: 5/30/2011
please help this newbie ?
Posted: 6/26/2011
The same issue is resolved here: http://www.codeasp.net/forums/asp-net-topics/data-access/715/how-to-add-modify-data-for-2-or-3-tables-at-the-same-time-plz-help