locked
Overload Resolution Failed Because... RRS feed

  • Question

  • User-1628398430 posted

    Hi there.  First post, sorry that its one that starts off with a problem :p .  Anyways, I'm a serious noob at ASP.NET (7 year php programmer, totally lost on ASP.NET), and I have gotten myself a pretty little error that I can't seem to get past.  I am working on a search results page which is pulling data from a stored procedure that queries an Oracle database.  Unfortunately my employer does not allow me any access to alter the stored procedures or the databases.  I have created a results page from a search query which returns the results in a datagrid view.  To get a full view of any given record, I have to create a URL that passes 3 unique record values in one query string.  Line 105 of the code below shows exactly where I am trying to make this dynamic url creation happen.

    Here is the error I get when compiling: Error 3 Overload resolution failed because no accessible 'ToString' accepts this number of arguments. 

    Lines 99 - 108 is the area of focus I suspect. Here is the code to handle all the action;

     

    1    Imports System.Data
    2    Imports System.Data.OracleClient
    3    Imports LossIncident
    4    
    5    Partial Class LossIncident_Search
    6        Inherits System.Web.UI.Page
    7        Dim objLI As New LossIncident
    8    
    9        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    10           'lblSummary.Text = ""'
    11           If Page.IsPostBack Then
    12               'get selected DDLs
    13               'assign selected DDLs
    14               'populate the DDLs
    15               'populate GridViews
    16           Else
    17               'fresh load, populate DDLs    
    18               getList(ddlService, "UNIFORMED SVC")
    19               getList(ddlRank, "RANK")
    20               getList(ddlPostRank, "RANK")
    21               getList(ddlUnit, "AS_CAS_INCNT_ID_CD", "MIL_ECHLN_TX", "MIL_ECHLN_TX", 2, ddlConflict.SelectedValue)
    22               getList(ddlVehicleClass, "VEHICLE CLASS")
    23               getList(ddlVehicleCode, "VEHICLE CODE")
    24               getList(ddlConflict, "INCIDENT ID")
    25               getList(ddlSource, "INCNT SOURCE")
    26               getList(ddlCountry, "COUNTRY")
    27               getList(ddlCountry2, "COUNTRY")
    28               getList(ddlStatus, "SITE STATUS")
    29   
    30           End If
    31       End Sub
    32   
    33       Public Sub getList(ByRef ddl As DropDownList, ByVal domain As String, Optional ByVal text As String = "DESCRIPTION", Optional ByVal value As String = "CODE", Optional ByVal proc As Integer = 1, Optional ByVal filter As String = "")
    34           Try
    35               ddl.DataTextField = text
    36               ddl.DataValueField = value
    37               ddl.DataSource = objLI.GetList(domain, proc, filter)
    38               ddl.DataBind()
    39               ddl.Items.Insert(0, "")
    40               ddl.SelectedItem.Selected = True
    41           Catch ex As Exception
    42               'lblError.Text = "Error getting list items for " + ddl.ID.ToString + ". Exeption: " + ex.ToString'
    43           End Try
    44       End Sub
    45       Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    46           Dim ci_ID, li_ID, li_SRCCD, li_Images, li_SiteNo, li_MGRS, li_Service, li_Rank, li_PostRank, li_Unit, li_VehicleClass, li_VehicleCode, li_VehicleID, li_VehicleCallName, li_Conflict, li_Number, li_Source, li_Country, li_From, li_To, li_Country2, li_KM, li_District, li_Province, li_Status As String
    47           Dim li_Limit As Integer
    48           Dim ds As DataSet
    49           Dim objOutput As New Object
    50           Try
    51               ci_ID = ""
    52               li_ID = ""
    53               li_SRCCD = ""
    54               li_Images = ""
    55               li_SiteNo = ""
    56               li_Service = ddlService.SelectedValue
    57               li_Rank = ddlRank.SelectedValue
    58               li_PostRank = ddlPostRank.SelectedValue
    59               li_Unit = ddlUnit.SelectedValue
    60               li_VehicleClass = ddlVehicleClass.SelectedValue
    61               li_VehicleCode = ddlVehicleCode.SelectedValue
    62               li_VehicleID = txtVehicleID.Text
    63               li_VehicleCallName = txtVehicleCallName.Text
    64               li_Conflict = ddlConflict.SelectedValue
    65               li_Number = txtNumber.Text
    66               li_Source = ddlSource.SelectedValue
    67               li_Country = ddlCountry.SelectedValue
    68               li_From = txtFrom.Text
    69               li_To = txtTo.Text
    70               li_Country2 = ddlCountry2.SelectedValue
    71               li_MGRS = txtMGRS.Text
    72               li_KM = txtKM.Text
    73               li_District = txtDistrict.Text
    74               li_Province = txtProvince.Text
    75               li_Status = ddlStatus.SelectedValue
    76               li_Limit = 1000
    77               ds = FindRecord(ci_ID, li_ID, li_SRCCD, li_From, li_To, li_Country, li_Country2, li_SiteNo, li_MGRS, li_KM, li_District, li_Province, li_Status, li_VehicleClass, li_VehicleCode, li_VehicleCallName, li_VehicleID, li_Images, li_Limit, objOutput)
    78   
    79               lblSummary.Text = "Search Completed " + Date.Now + ". We found a total of " + objOutput.Value().ToString + " records matching your criteria. We are displaying up to " + li_Limit.ToString() + " records."
    80               dgCISearch.DataSource = ds
    81               dgCISearch.DataBind()
    82               btnExport.Enabled = True
    83           Catch ex As Exception
    84               lblError.Text = "Error getting your search results. Exeption: " + ex.ToString
    85           End Try
    86       End Sub
    87   
    88       Public Function FormatString(ByVal str As String) As String
    89           Dim msg As String
    90           msg = ""
    91   
    92           If str = "" Then
    93               Throw New ArgumentOutOfRangeException("id")
    94           Else
    95               msg = str
    96           End If
    97           Return msg
    98       End Function
    99       Public Function FormatLI(ByVal CAS_INCNT_ID_CD As String, ByVal LOSS_INCNT_NR As String, ByVal LOSS_INCNT_SRC_CD As String) As String
    100          Dim msg As String
    101          msg = ""
    102          If msg = "" Then
    103              Throw New ArgumentOutOfRangeException("id")
    104          Else
    105              msg = "../LossIncident/Details.aspx?FULL_NM=" + CAS_INCNT_ID_CD + "-" + LOSS_INCNT_NR + "-" + LOSS_INCNT_SRC_CD
    106          End If
    107          Return msg
    108      End Function
    109  
    110  
    111      Protected Sub BtnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
    112          Response.Clear()
    113          Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
    114          Response.Charset = ""
    115  
    116          ' If you want the option to open the Excel file without saving then
    117          ' comment out the line below
    118          ' Response.Cache.SetCacheability(HttpCacheability.NoCache);
    119          Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    120          Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
    121          Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
    122          dgCISearch.RenderControl(htmlWrite)
    123          Response.Write(stringWrite.ToString())
    124          Response.End()
    125      End Sub
    126  
    127      Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
    128  
    129  
    130      End Sub
    131  
    132  End Class
    

     

    Ok, so theres that.  Now the aspx page that shows the results, and more specifically, how I'm calling the link;

    <asp:TemplateField HeaderText="Full Name">
    <ItemTemplate>
    <asp:HyperLink ID="hlUrl" runat="server" NavigateUrl='<%# FormatLI(Eval("CAS_INCNT_ID_CD"),Eval("LOSS_INCNT_NR"),Eval("LOSS_INCNT_SRC_CD ")) %>' Target='_blank' Text='<%# Eval("CAS_INCNT_ID_CD"),Eval("LOSS_INCNT_NR"),Eval("LOSS_INCNT_SRC_CD ") %>' /> 
    </ItemTemplate>
    </asp:TemplateField>
     

     

    Monday, November 17, 2008 6:53 PM

Answers

  • User1006193418 posted

    Hi there.  First post, sorry that its one that starts off with a problem :p .  Anyways, I'm a serious noob at ASP.NET (7 year php programmer, totally lost on ASP.NET), and I have gotten myself a pretty little error that I can't seem to get past.  I am working on a search results page which is pulling data from a stored procedure that queries an Oracle database.  Unfortunately my employer does not allow me any access to alter the stored procedures or the databases.  I have created a results page from a search query which returns the results in a datagrid view.  To get a full view of any given record, I have to create a URL that passes 3 unique record values in one query string.  Line 105 of the code below shows exactly where I am trying to make this dynamic url creation happen.

    Here is the error I get when compiling: Error 3 Overload resolution failed because no accessible 'ToString' accepts this number of arguments. 

    Lines 99 - 108 is the area of focus I suspect. Here is the code to handle all the action;

    Hi seohonolulu,

    I noticed that you have located msg = "" at line 101 and cause by this, it seems like the function FormatLI will always return a empty string and throw a exception right? If I have misunderstood something, feel free to let me know.

    And also, I would like to suggest you setting the NavigateUrl and Text properties of the HyperLink in Code-Behind. You can locate such the codes in Page_PreRender event handler.

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 20, 2008 2:48 AM