Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-10-14
5
Medium Priority
?
891 Views
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)
        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

0
Comment
Question by:rcowen00
  • 2
  • 2
5 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 36972185
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.
Check:
http://msdn.microsoft.com/en-us/library/aa581785.aspx
(see figure 8 and generated markup)
0
 

Author Comment

by:rcowen00
ID: 36974129
dtlClients is a detailview
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 36974614
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36976620
Did you try

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

Author Comment

by:rcowen00
ID: 36976826
Code Cruser, I had tried that and it did not work.  Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 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