Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
code:
SQL
If rdbPO.Checked = True And ddl_PO_Cod.SelectedValue.ToString <> -1 Then
         
  btnPrint.Attributes.Add("onclick", "window.open('Reports.aspx?rptid=11&val= '" & ddl_PO_Cod.SelectedValue.ToString & "','','location=0,resizable=0,ScrollBars=1,statusbar=1,width=980,height=800,left=20,top=10,moveable=0') ;return false")
           End If


REPORTS.ASPX CODE

SQL
Case "11"
               report.Load(Server.MapPath("Reports/RepOPODevice.rpt"))
               CRptViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
               report.RecordSelectionFormula = "{TBL_DEVMASTER.PONO}=" & Request.QueryString("Val").ToString
               Page.Title = "PODevice Reports"
Posted
Updated 15-Sep-13 0:40am
v3
Comments
[no name] 15-Sep-13 6:46am    
Was there, maybe, some sort of a question?
Richard MacCutchan 15-Sep-13 7:39am    
Don't use ToString everywhere unless you understand what it is actually doing. For example, why are you converting a value to a string and then trying to compare it with the value -1?

1 solution

In your First line
VB
If rdbPO.Checked = True And ddl_PO_Cod.SelectedValue.ToString <> -1 Then

write condtion like this
VB
If rdbPO.Checked = True And ddl_PO_Cod.SelectedValue.ToString <> "-1" Then
OR
VB
If rdbPO.Checked = True And Convert.ToInt32(ddl_PO_Cod.SelectedValue) <> -1 Then

Like this..


When you are comparing two strings then strings must be in " "(i.e double inverted comma)

Or if you sure about your selected value is Integer then use
VB
Convert.ToInt32(combobox.SelectedValue)
 
Share this answer
 
Comments
akhil.krish 16-Sep-13 1:53am    
Thanks for reply

iam use same u r code... but error comes like this

A string is required here. Details: errorKind Error in File RepOPODevice {F2C06A73-C223-4BF9-ABFA-391D2B70062B}.rpt: Error in formula Record_Selection: '{TBL_DEVMASTER.PONO}= 6169/801//17' A string is required here. Details: errorKind
akhil.krish 16-Sep-13 1:55am    
If rdbPO.Checked = True And ddl_PO_Cod.SelectedIndex <> "-1"

this is also same problem ....
Jigar Sangoi 16-Sep-13 2:13am    
Now you are using SelectedIndex and selected index always a number
not a string, you have written -1 as String (i.e "-1") this is wrong

Write like this:
If rdbPO.Checked = True And ddl_PO_Cod.SelectedIndex <> -1

and now check what error comes and describe here
Jigar Sangoi 16-Sep-13 2:33am    
Also change line and check your problem is solve or not

report.RecordSelectionFormula = "{TBL_DEVMASTER.PONO}='" & Request.QueryString("Val").ToString & "'"
akhil.krish 16-Sep-13 2:46am    
Jigar Sangoi Thanks it's working fine but empty reports showing....please help it is very urgent...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900