Link to home
Start Free TrialLog in
Avatar of rcowen00
rcowen00Flag for United States of America

asked on

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

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)
        Try
            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
            cnn.Open()
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
        Finally
            cnn.Close()
        End Try
    End Sub

Open in new window

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcowen00

ASKER

dtlClients is a detailview
Solution:
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.
Did you try

cmd.Parameters.Add("@ClientID ", Data.SqlDbType.Int).Value = CInt(dtlClients.SelectedValue)
Code Cruser, I had tried that and it did not work.  Thank you.