Click here to Skip to main content
12,290,956 members (58,469 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
I am developing a websie in and I have done a GridView Binding.when i run the website or program then i find this error:---

"error-exception has been thrown by the target of an invocation"
Give me the proper answer.
my sample code for the binding is given below:--

In aspx page:-
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
            CellPadding="4" ForeColor="#333333" GridLines="Horizontal"
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" />
            <asp:TemplateField HeaderText="UserId" Visible="false">
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("userid") %>'></asp:TextBox>
            Field of Work2
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("userid") %>'>

           <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
           <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
           <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
           <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
           <EditRowStyle BackColor="#999999" />
           <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
Posted 20-Sep-11 20:56pm
arathi_suresh 21-Sep-11 3:20am
Show the binding code
hitech_ssc 21-Sep-11 4:22am
if you dont mind place a break point and debug your code ...
tell us where you are getting the error message...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Root cause for this issue might be the solution file CPU-flavor references become corrupted. To fix this issue:

1. Open the .sln file in notepad
2. Change All References to"AnyCPU"
3. Save
4. Open the solution again
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

it is not a web specific error, well ...

1.ensure that a value is being returned fron the databse. Otherwise you will get this error.

2.if u r using ajax and script manager then: Disable the ajax for a moment (EnablePartialRendering="false" on the scriptmanager).
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

This error is throwned when a control is not supported by Asp.Net..

That is if you are using a control developed for windows in Asp.Net then this error is throwned
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Check the inner exception of the error for specific error message. I had the same problem and it was dues to insufficient parameters being passed to a stored procedure.

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

Advertise | Privacy | Mobile
Web01 | 2.8.160518.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100