Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="確定" />

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <rsweb:ReportViewer ID="ReportViewer1"  runat="server" Font-Names="Verdana" 
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="800px" 
        Height="600px" Visible="false">
        <LocalReport ReportPath="rdlc\absent_form.rdlc">
        </LocalReport>
    </rsweb:ReportViewer>


C#
protected void Button1_Click(object sender, EventArgs e)
    {
        var conString = ConfigurationManager.ConnectionStrings["ConnectionString"];
        string strConnString = conString.ConnectionString;
        SqlConnection conn = new SqlConnection();

        using (conn = new SqlConnection(strConnString))
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }


            ReportViewer1.Visible = true;
        }


Here's i get problem, I set the reportviewer's visible as false in the beginning, when the user press the button, then it will turn to true, but however it doesn;t work. May i know if there anything i get mistakes. Please help....
Posted

on Page load
C#
reportViewer1.Visible="false"

and on Button Click

C#
ReportViewer1.Visible = true;


VB
<rsweb:ReportViewer ID="ReportViewer1"  runat="server" Font-Names="Verdana"
       Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
       WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="800px"
       Height="600px">
 
Share this answer
 
Comments
Mohit_Patel 9-Oct-15 7:58am    
This is wrong answer.
Visible is always expecting bool (either true or false).
If you do reportViewer1.Visible="false" then it will give you an error.

I am facing the same visibility issue and will post a solution if have anything which works properly.
Do not set Visible="false" in HTML.

Instead of that set Report Body visibility on Page Load and make it visible on button click event as shown below:

On Page Load
C#
ReportViewer1.ShowReportBody = false;


On Button Click
C#
ReportViewer1.ShowReportBody = true;


VB
<rsweb:ReportViewer ID="ReportViewer1"  runat="server" Font-Names="Verdana"
       Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
       WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="800px"
       Height="600px">
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900