Hi @Kerry Ou ,
The common steps for adding RDLC report in webforms are:
- Prepare Typed DataSet => .xsd file in webforms
- Add RDLC Report with DataSet => .rdlc file in webforms
- Add ReportViewer and change the mode to local and attach it with the .rdlc file path
- Populate the RDLC Report from Database
It seems like you have completed the previous 3 steps. Do you want to know how to populate the data?
Your codes contain two DataSource controls, a) ObjectDataSource b) SqlDataSource. I don't think you need both to bind the data. You could refer to below demo using mock data from my side:
- User (UserId, Name, Country) where UserId is the key and will be used to fetch data
- TextBox will automatically trigger a postback if the text is changed and refresh the ReportView content
- Set 'ProcessingMode' to 'Local' (necessary) and Set up a <Datasource> for <LocalReport>
ASPX:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Local" Font-Names="Verdana" Font-Size="8pt" BackColor="" ClientIDMode="AutoID" HighlightBackgroundColor="" InternalBorderColor="204, 204, 204" InternalBorderStyle="Solid" InternalBorderWidth="1px" LinkActiveColor="" LinkActiveHoverColor="" LinkDisabledColor="" PrimaryButtonBackgroundColor="" PrimaryButtonForegroundColor="" PrimaryButtonHoverBackgroundColor="" PrimaryButtonHoverForegroundColor="" SecondaryButtonBackgroundColor="" SecondaryButtonForegroundColor="" SecondaryButtonHoverBackgroundColor="" SecondaryButtonHoverForegroundColor="" SplitterBackColor="" ToolbarDividerColor="" ToolbarForegroundColor="" ToolbarForegroundDisabledColor="" ToolbarHoverBackgroundColor="" ToolbarHoverForegroundColor="" ToolBarItemBorderColor="" ToolBarItemBorderStyle="Solid" ToolBarItemBorderWidth="1px" ToolBarItemHoverBackColor="" ToolBarItemPressedBorderColor="51, 102, 153" ToolBarItemPressedBorderStyle="Solid" ToolBarItemPressedBorderWidth="1px" ToolBarItemPressedHoverBackColor="153, 187, 226" Width="1597px">
<LocalReport ReportPath="Outstanding.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
</div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="RDLCVB.OutstandingTableAdapters.UsersTableAdapter">
<SelectParameters>
<asp:FormParameter DefaultValue="1" FormField="TextBox1" Name="userId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<br />
<asp:TextBox ID="TextBox1" runat="server" Text="1" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
</form>
Code behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
ReportViewer1.LocalReport.Refresh()
End Sub
Other files in demo: Outstanding.xsd as a Typed DataSet, Outstanding.rdlc as a report component
Result:
By the way, you could check the C# version and use C# - VB converter to converter the codes since rarely can you see the VB version example for report viewer
Hope this helps.
Best regards,
Sean
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.