Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with highlighting text entered from textbox in  MS Report

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

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

783 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