?
Solved

Help with highlighting text entered from textbox in  MS Report

Posted on 2012-04-06
6
Medium Priority
?
437 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
 

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
Technology Partners: 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 2000 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

718 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