Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help with highlighting text entered from textbox in  MS Report

Posted on 2012-04-06
6
429 Views
Last Modified: 2012-04-30
Hello,

I am using the code below to display Receiver and Donor in my report, How do I modify the code or the report to change the text color of receiver where the receiver matches receiver entered in my textbox?

Dim dt As New DataTable()
        dt.TableName = "Links"
        dt.Columns.Add("Link_ID")

        dt.Columns.Add("Receiver")

        dt.Columns.Add("Donor")



        Dim linker As XElement = XElement.Load(Application.StartupPath + "\Link.xml")
        Dim receiver As XElement = XElement.Load(Application.StartupPath + "\Receiver.xml")
        Dim Donor As XElement = XElement.Load(Application.StartupPath + "\Donor.xml")



        For Each item As XElement In linker.Elements("Row")

            Dim linkID As String = item.Element("Link_ID").Value
            Dim receiverId As String = item.Element("Receiver_ID").Value
            Dim DonorID As String = item.Element("Donor_ID").Value 'Add (3)
            Dim receiverVal As String = String.Empty
            Dim xe As XElement = receiver.Elements("Row").Cast(Of XElement)().Where(Function(n) n.Element("Receiver_ID").Value = receiverId).FirstOrDefault()



            If xe IsNot Nothing Then

                receiverVal = xe.Element("Receiver").Value

            End If



            Dim DonorVal As String = String.Empty

            xe = Donor.Elements("Row").Cast(Of XElement)().Where(Function(n) n.Element("Donor_ID").Value = DonorID).FirstOrDefault()

            If xe IsNot Nothing Then

                DonorVal = xe.Element("Donor").Value

            End If


            Dim dr As DataRow = dt.NewRow()
            dr("Link_ID") = linkID
            dr("Receiver") = receiverVal
            dr("Donor") = DonorVal 'Add (5)
            dt.Rows.Add(dr)

        Next


        Dim bs As New BindingSource()

        bs.DataSource = dt
        'dt.WriteXml(" D:\XMLoutput.xml") - Use this trick to create XML to design report

        Dim reportDataSource As New Microsoft.Reporting.WinForms.ReportDataSource()
        'reportDataSource.Name = "DocumentElement_Links"
        reportDataSource.Name = "MyDataSet_Links"
        reportDataSource.Value = dt

        ReportViewer1.LocalReport.DataSources.Add(reportDataSource)
        ReportViewer1.LocalReport.Refresh()
        ReportViewer1.RefreshReport()
0
Comment
Question by:vcharles
  • 3
  • 2
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37819710
0
 

Author Comment

by:vcharles
ID: 37819973
Hi,

Took the code below from one of the links but it still doesn't work, any ideas what is wrong with the syntax below?

=iif("ReportItems!textbox1.Value / Fields!Donor.Value", "Red", "Black")

Thnaks,

Victor
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 37841328
any ideas what is wrong with the syntax below?

=iif("ReportItems!textbox1.Value / Fields!Donor.Value", "Red", "Black")

ReportItems!textbox1.Value is a string and thus the division would not work.  You can use a conversion function such as CLng to convert it back to number.
Also, the expression should not be enclosed in double quotes.

Corrected:
=iif(CLng(ReportItems!textbox1.Value) / Fields!Donor.Value, "Red", "Black")

BTW: this assumes that textbox1 actually contains a numeric value without decimal separator.
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:vcharles
ID: 37841803
Thanks, In some cases I will also be entereing Text in Textbox1(aspx form), which is a problem because Textbox does not have a value property. How do I modify the code to compare Text values between Textbox2 in my report and Textbox1 from my aspx form?
0
 

Author Comment

by:vcharles
ID: 37841812
In some cases your approach would work when I use a combo box which has a value property, but as mentioned I will primarily be using Textboxes.
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 37841870
Just to be clear: that expression that you pasted is coming from inside the report, right?  Because it's an SSRS expression, not .NET code.   And the ReportItems collection refers to the collection of textboxes inside the report, not on your ASPX page.

So to be able to use the value from a textbox on your page inside the report, you could create a report parameter and pass it in using that.

Also, try to avoid using the same textbox for two different purposes (string vs. number). It only makes things more complicated.

A couple of links that could help getting that param implemented:
http://msdn.microsoft.com/en-us/library/aa337432(v=sql.105).aspx
http://msdn.microsoft.com/en-us/library/ms252178(v=vs.90).aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by Valentino Vranken. Introduction: The first step of creating a SQL Server Reporting Services (SSRS) report involves setting up a connection to the data source and programming a dataset to retrieve data from that data source.  The data…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question