Conversion from string "__Page" to type 'Integer' is not valid.

Posted on 2011-10-14
Last Modified: 2012-08-13
I have a detailsview that I am pulling as a parameter, but it appears to be pulling the wrong information
Protected Sub btnInsertNewException_Click(sender As Object, e As EventArgs) Handles btnInsertNewException.Click
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.ClientReportExceptionInsert"
            cmd.Parameters.Add("@ReportTypeID ", Data.SqlDbType.Int).Value = Int32.Parse(txtReportTypeID.SelectedItem.Value)
            cmd.Parameters.Add("@ExceptionFee ", Data.SqlDbType.Char).Value = txtExceptionFee.Text
            cmd.Parameters.Add("@ExceptionTurnTime ", Data.SqlDbType.Char).Value = txtExceptionTurnTime.Text
            cmd.Parameters.Add("@ClientID ", Data.SqlDbType.Int).Value = CInt(ClientID)
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.Int).Value = 1
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
        End Try
    End Sub

Open in new window

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server">
    <asp:ControlParameter  ControlID="dtlClients" Name="ClientID" PropertyName="SelectedValue" />

Open in new window

Question by:rcowen00
    LVL 35

    Accepted Solution

    What kind of control is dtlClients?

    Just remember that ClientID can only be used for the object data source SelectMethod only, that is not shown here.
    (see figure 8 and generated markup)

    Author Comment

    dtlClients is a detailview
    LVL 35

    Expert Comment

    by:Miguel Oz
    My previous comment stands. you can not use object data source without a SelectMethod.

    Alternative: What you can do if Sub btnInsertNewException_Click is in the same page as dtlClients is to access directly (enabling view state) else you need to save the required value in Session object so other page can access it. You may need to open another question detailing markup of both detail view and target page.
    LVL 83

    Expert Comment

    Did you try

    cmd.Parameters.Add("@ClientID ", Data.SqlDbType.Int).Value = CInt(dtlClients.SelectedValue)

    Author Comment

    Code Cruser, I had tried that and it did not work.  Thank you.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my 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…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now