How to concatenate values in RDLC expression? - asp.net

I have an RDLC file in which I want to make an expression.
Here is the image of properties of expression. I need to concatenate First Name, Last name and Middle Init.

The following examples works for me:
=Fields!FirstName.Value & " " & Fields!LastName.Value
or
="$ " & Sum(Round((Fields!QTD_ORDER.Value - Fields!QTD_RETURN.Value) * Fields!PRICE.Value,2), "Entity_orderItens")
Have a look at MSDN

Check this : http://blogs.msdn.com/b/mosharaf/archive/2005/12/20/localreportcustomcode.aspx
it is possible to do in a different way in the rdlc report you can use VB code. Just click on the report with right mouse button. When the context menu from where you enter parameters go to Proprties. When clicking it you should see a tab control witch few tab pages. Go to tab page "Code" an there right you VB function it must be something like this
Public Function concatestring(ByVal val1 As Object,ByVal val2 As Object,ByVal val3 As Object ) As String
// return val1 + ' ' + val2 + ' ' + val3 -- just string cocate in vb will do your task
End Function
Then call the function in your textbox like this
= Code.concatestring(Fields!MyField_1.Value,Fields!MyField_2.Value,Fields!MyField_3.Value )
P.S. I am not very sure if the VB code is working correctly just test it and if it is needed rewrite. If any other error occurs please post it to see what is the problem

Related

VBA for extracting Data from URL

I am trying to get some data from google map with VBA to extract in to excel. as I am not expert in VBA so facing some problem. in side google map, if we scroll to down there are some web result links coming in script. I want to extract that link if possible. here I try from my end but not getting actually result what I want
here is screen shot for web result of google map url
also here I some code which I try but not success
Public Sub GmapData()
'On Error Resume Next
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "https://g.page/MiguelLopezSalon?share" ' try with first URLS and second
Do
DoEvents
Loop Until ie.readystate <> 4
Application.Wait (Now + TimeValue("00:00:15"))
Dim MyData As New MSForms.DataObject
MyData.GetFromClipboard
For N = 0 To ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Length - 1
If ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Item(N).innerText = "About this data" Then
ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Item(N).ScrollIntoView (False)
End If
Next N
Application.Wait (Now + TimeValue("00:00:05"))
GMD = ie.document.getElementsByClassName("trex").Item(0).innerHTML ' facing error here
ActiveSheet.Cells(1, 1).Value = GMD
End Sub
I try to google on my issue.. then found its a iframe inside html.. also try with following code line but still not get result
ie.document.getElementsByTagName("iframe")(0).document.getElementsByClassName("trex").Item(0).innerHTML
Please anyone can me help out. to extract data within Ifram

Second Dynamic DIV over writes first dynamic DIV

I have searched for almost three days now and I can't find an answer to this question. As I am somewhat new to ASP.Net I am not sure what the problem is.
Here is the situation. I have an aspx page that has a web form on it. When this form loads it has two SQL queries that execute and populate different controls.
My problem lies not with the queries but creating dynamic DIV tags and adding controls to them. If the query returns one or no records everything is fine. but if there are 2 or more records returned I only end up with the last record being displayed.
When I view the page source (from the browser) I can see the DIV tag ID that was created last, but the first DIV tag is gone. It is like the first DIV tag gets over written or something. I have no idea as to why or what is causing this.
Can anyone help please?
Here is my code:
While (incCounter <= rowCount)
DivName.ID = ("rev" & Convert.ToString(incCounter)) 'Create Div name of rev and the current counter number ex. rev1
review_comments.Controls.Add(DivName) 'Add DIV to web form
rName = (rName & Convert.ToString(incCounter)) 'Create name control name
rDate = (rDate & Convert.ToString(incCounter)) 'Create date control name
rComments = (rComments & Convert.ToString(incCounter)) 'Create comment control name
DivName.Controls.Add(New LiteralControl("<br />"))
DivName.Controls.Add(rRevByLabel)
rNameTextBox.ID = rName
DivName.Controls.Add(rNameTextBox)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(rDateLabel)
DivName.Controls.Add(rDateTextBox)
DivName.Controls.Add(New LiteralControl("<br />"))
DivName.Controls.Add(rCommentLabel)
DivName.Controls.Add(rCommentsTextBox)
'Assign data from query to new textboxes
rNameTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_name").ToString()
rDateTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_date").Date()
rCommentsTextBox.Text = dtR.Rows(incCounter - 1)("review_comments").ToString()
rName = "revName"
rDate = "rDate"
rComments = "revComments"
incCounter += 1
End While
I know all the variables are set up correctly because it shows me the last record.
What stupid thing am I doing?

Access 2007 - Referring to sub-report value from sub-sub-report

I have a report that has several sub-reports as well as a sub-report to one of the sub-reports.
The one that concerns me:
rptProgressReport ->rptEmployee (sub of rptProgressReport) -> rptSubEmployeeProject (sub of rptEmployee)
So far everything is generating as needed. Employees list in order, and the sub-report pulls out various project details. Except I need to add together time spent from one table.
tblProject (main table) -> tblProjectHistory (related table to tblProject via projectID->fldProjectID).
tblProjectHistory has the following fields.
[historyID],[fldProjectID], [History Information], [History Date], [Time Spent], [Employee].
I need to do a sum of all [Time Spent] for projects that equal what is being displayed and as long as the employee matches and the date is within the specified date range.
Specified date range is via the launching Form (frmReportGeneration) with fields txtStartDate and txtEnd Date.
Sub-report rptSubEmployeeProject has a text box (txtTimeSpent) that I have the following for a control source.
=Sum(DLookUp("[Time Spent]","tblProjectHistory","[Employee]='" & [Reports]![rptEmployee].[txtTempEmployee] & "' AND [History Date] > " & [Forms]![frmReportGeneration].[txtStartDate] & " AND " & [History Date]<" & [Forms]![frmReportGeneration].[txtEndDate] & "))
the rptEmployee field of txtTempEmployee correctly displays the current employee to match in that sub-report.
The problem is I get prompted for each value part of the above code - txtTempEmployee and txtStartDate/txtEndDate, even if I change the report value to be [Reports]![rptProgressReport]![rptEmployee].[txtTempEmployee]
Any idea how to correctly pull variables from the parent report or the first sub-report?
Thank you.
+++++ Update +++++
Okay update/close on this. I ended up needing to do something similar to what was suggested in the accepted answer. I could not get the idea posted to work - but i was able to set tempvars in vba and used those throughout the report/sub-report(s).
it is not recommended to refer to other objects via this construct "Forms!...." (or "Reports!...")
i made some bad experience with it. i suggest to put the values into a variable and make a
Get-Funktion:
in a Module you define:
Publicg dtStart As Date
Public gdtEnd As Date
in the form you assign the start and end date in the button where you fire the report
gdtStart = Me!txtStartDate
gdtEnd = Me!txtEndDate
now the Get-Function:
Public Function Get_Date_Start () As Date
Get_Date_Start = gdtStart
End Function
Public Function Get_Date_End () As Date
Get_Date_End = gdtEnd
End Function
in the Query you can use it now like this:
... AND [History Date] > " & Get_Date_Start() & " AND " & [History Date] <" & Get_Date_End()
BTW: don't use spaces in any object-name: instead of [History Date] name it History_Date, you can avoid Brackets in Code :-)

Displaying a value as an image in vb

In my aspx page I have a gridview which displays the value from my database as "*". So if a value in my database table is 5, it will be displayed as "*****" in the gridview.
code in aspx:
<asp:TemplateField HeaderText="Rating" SortExpression="Rating">
<ItemTemplate><h1><%# getrating(Eval("Rating"))%></h1></ItemTemplate>
</asp:TemplateField>
code in aspx.vb
Protected Function getrating(ByVal rate As Integer)
Dim retval As String
retval = ""
For i = 1 To rate
retval = retval + "*"
Next
Return retval
End Function
What I want to do is change that "*" to a picture, ie star.jpg, so in the gridview it will display the image star.jpg instead of "*".
Any idea on how to do this please? Using MS visual studio 2010
You should be able to just do something like the following:
retval = retval + "<img src=""star.jpg"" alt=""*"">"
You may need some styling to put them all on the same line (float:left should do) but I forget offhand whether that is necessary.
The principle of this is obviously pretty basic. In the outputted HTML you will just have an image tag where before you had a *. A neater way to do it might be to have five images for one to five and then have something like:
Protected Function getrating(ByVal rate As Integer)
Dim retval As String
retval = String.Format("<img src=""Star{0}.jpg"" alt=""{0} stars"">", rate)
Return retval
End Function
This will output an image tag pointing to any of Star1 to Star5. This is nicer in some ways because it allows better control over how they look as well as allowing you to make five identical sized images and know that the space used will always be the same.
Here's an implementation using CSS - http://www.thebroth.com/blog/119/css-rating-stars - does require additional divs and two images to create effect but seems to be a neat solution.

Obtain data from dynamically incremented IDs in JQuery

I have a quick question about JQuery. I have dynamically generated paragraphs with id's that are incremented. I would like to take information from that page and bring it to my main page. Unfortunately I am unable to read the dynamically generated paragraph IDs to get the values. I am trying this:
var Name = ((data).find("#Name" + id).text());
The ASP.NET code goes like this:
Dim intI As Integer = 0
For Each Item As cItem in alProducts1
Dim pName As New System.Web.UI.HtmlControls.HtmlGenericControl("p")
pName.id = "Name" & intI.toString() pName.InnerText = Item.Name controls.Add(pName) intI += 1
Next
Those name values are the values I want...Name1, name2, name3 and I want to get them individually to put in their own textbox... I'm taking the values from the ASP.NET webpage and putting them into an AJAX page.
Your question is not clear about your exact requirement but you can get the IDs of elements with attr method of jQuery, here is an example:
alert($('selector').attr('id'));
You want to select all the elements with the incrementing ids, right?
// this will select all the elements
// which id starts with 'Name'
(data).find("[id^=Name]")
Thanks for the help everyone. I found the solution today however:
var Name = ($(data).find('#Name' + id.toString()).text());
I forgot the .toString() part and that seems to have made the difference.

Resources