Solved

Help with highlighting text entered from textbox in  MS Report

Posted on 2012-04-06
6
432 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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