Solved

Help with highlighting text entered from textbox in  MS Report

Posted on 2012-04-06
6
424 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now