Filter ReportViewer based on RadioButtonList selection using ReportParameter in ASP.Net

Last Reply 19 days ago By kankon

Posted 21 days ago

I am working with report viewer using radiobuttonlist with session

the Second page display with selected from radio button work very well also with report viewer

the problem i got all display, i have now 3 control 

if i selected first (ReportUser) to true i want other flase like to hide second Reportop third ReportBoss from report viewer 

i add to expression for hidden

first =(Parameters!ReportUser.Value = "False")

second =(Parameters!Reportop.Value = "False")

third=(Parameters!ReportBoss.Value = "False")

HTML

<asp:RadioButtonList ID="RadioButtonList5" runat="server" AutoPostBack="true" BorderColor="#333333" BorderStyle="Solid" CssClass="auto-style186" ForeColor="Black" OnSelectedIndexChanged="RadioButtonLissRasmi" RepeatDirection="Horizontal" style="font-size: large" TextAlign="Left" Width="100%">
    <asp:ListItem Value="ReportUser">موظف</asp:ListItem>
    <asp:ListItem Value="Reportop">اشرافي</asp:ListItem>
    <asp:ListItem Value="ReportBoss">مدير الادارة</asp:ListItem>
</asp:RadioButtonList>

then i use sesson

protected void RadioButtonLissRasmi(object sender, EventArgs e)
{
    Session["Gender_Rsmi"] = RadioButtonList5.SelectedValue;
}

the second page 

HTML

        <asp:TextBox ID="txtUsername" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>
        <asp:Image ID="Image1" runat="server" Height="50px" Width="50px" />

         <asp:TextBox ID="fileid" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>

         <asp:TextBox ID="civilid0" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>

         <asp:TextBox ID="emetoday" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>
         <br />
         <asp:TextBox ID="emetoday0" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>
         <asp:TextBox ID="markazel3mel" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>
         <asp:TextBox ID="joptitel" Style="text-align: center" runat="server" Enabled="False"></asp:TextBox>
         <asp:Label ID="lblGender" runat="server"></asp:Label>
         <br />                                             
         <br />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div class="msrs-printdialog-pdfcontainer">
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="800px" Width="100%">
        </rsweb:ReportViewer>

c#

        protected void Page_Load(object sender, EventArgs e)
        {
            lblGender.Text = Session["Gender_Rsmi"].ToString();
            EMEmonth.Text = Session["rsmonth0"].ToString();
            EMEtotal.Text = Session["rsmtotal0"].ToString();
            emetoday0.Text = Session["rsmdate"].ToString();
            emetoday.Text = Session["rsmtime"].ToString();
            txtUsername.Text = Session["name"].ToString();
            fileid.Text = Session["filenumber"].ToString();
            joptitel.Text = Session["location"].ToString();
            markazel3mel.Text = Session["markazel3mel"].ToString();
            civilid0.Text = Session["civilid"].ToString();
            Image1.ImageUrl = Session["filelocation"].ToString();

            if (!this.IsPostBack)
            {
                DataSet1 dsCustomers = new DataSet1();
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/reportviewer/Report3.rdlc");
                ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[0]);
                ReportParameter[] param = new ReportParameter[8];
                param[0] = new ReportParameter("nameParameter", txtUsername.Text);
                param[1] = new ReportParameter("fileidParameter", fileid.Text);
                param[2] = new ReportParameter("locationParameter2", joptitel.Text);
                param[3] = new ReportParameter("workParameter", markazel3mel.Text);
                param[4] = new ReportParameter("civilParameter", civilid0.Text);
                param[5] = new ReportParameter("timeParameter", emetoday.Text);
                param[6] = new ReportParameter("dateParameter", emetoday0.Text);
                param[7] = new ReportParameter("imagesbarcode", Image1.ImageUrl.Replace("data:image/png;base64,", ""));

                ReportViewer1.LocalReport.SetParameters(param);
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(datasource);

                if (lblGender.Text == "ReportUser")
                {
                    ReportParameter textmsg = new ReportParameter("ReportUser", "true");
                    ReportViewer1.LocalReport.SetParameters(textmsg);
                }
                else
                {
                    ReportParameter textmsg4 = new ReportParameter("Reportop", "flase");
                    ReportViewer1.LocalReport.SetParameters(textmsg4);
                    ReportParameter textmsg5 = new ReportParameter("ReportBoss", "false");
                    ReportViewer1.LocalReport.SetParameters(textmsg5);
                    ReportViewer1.LocalReport.Refresh();
                }

                if (lblGender.Text == "Reportop")
                {
                    ReportParameter textmsg6 = new ReportParameter("Reportop", "true");
                    ReportViewer1.LocalReport.SetParameters(textmsg6);
                    ReportViewer1.LocalReport.Refresh();
                }
                else
                {
                    ReportParameter textmsg2 = new ReportParameter("ReportUser", "false");
                    ReportViewer1.LocalReport.SetParameters(textmsg2);
                    ReportParameter textmsg7 = new ReportParameter("ReportBoss", "false");
                    ReportViewer1.LocalReport.SetParameters(textmsg7);
                    ReportViewer1.LocalReport.Refresh();
                }

                if (lblGender.Text == "ReportBoss")
                {
                    ReportParameter textmsg8 = new ReportParameter("ReportBoss", "true");
                    ReportViewer1.LocalReport.SetParameters(textmsg8);
                }
                else
                {
                    ReportParameter textmsg3 = new ReportParameter("ReportUser", "false");
                    ReportViewer1.LocalReport.SetParameters(textmsg3);
                    ReportParameter textmsg9 = new ReportParameter("Reportop", "false");
                    ReportViewer1.LocalReport.SetParameters(textmsg9);
                    ReportViewer1.LocalReport.Refresh();
                }

                ReportViewer1.LocalReport.Refresh();
            }

 

You are viewing reply posted by: kankon 19 days ago.
Posted 19 days ago Modified on 18 days ago

update :

must be same spill cap

Yellow : =(Parameters!ReportUser.Value = "False")

RED : =(Parameters!ReportBoss.Value = "False")

Green : =(Parameters!Reportop.Value = "False")

ReportParameter textmsg = new ReportParameter("ReportUser", "True");
ReportParameter textmsg = new ReportParameter("ReportUser", "False");