Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB ASP.NET
I have a problem in my code.
I always have an error.
 
Here is my code
 
<pre lang="xml"><asp:GridView ID="GridView1" runat="server"
              AutoGenerateColumns="False"
              DataKeyNames="ID"
              DataSourceID="SqlDataSource1"
              OnRowDeleted="GridView1_RowDeleted"
              OnRowUpdated="GridView1_RowUpdated"
              ShowFooter="true"
              OnRowCommand="GridView1_RowCommand">
<Columns>
    <asp:CommandField ShowDeleteButton="True"
                      ShowEditButton="True" />
    <asp:TemplateField HeaderText="ID" SortExpression="ID">
    <ItemTemplate>
    <asp:Label ID="lblID" runat="server"
                          Text='<%#Eval("ID") %>'>
    </asp:Label>
    </ItemTemplate>
    <FooterTemplate>
    <asp:Button ID="btnInsert" runat="server"
                Text="Insert" CommandName="Add" />
    </FooterTemplate>
    </asp:TemplateField>
 
    <asp:TemplateField HeaderText="FirstName"
                       SortExpression="FirstName">
    <ItemTemplate>
    <asp:Label ID="lblFirstName" runat="server"
               Text='<%#Eval("FirstName") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtFirstName" runat="server"
                 Text='<%#Bind("FirstName") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtFname" runat="server">
    </asp:TextBox>
    </FooterTemplate>
    </asp:TemplateField>
 
    <asp:TemplateField HeaderText="LastName"
                       SortExpression="LastName">
    <ItemTemplate>
    <asp:Label ID="lblLastName" runat="server"
               Text='<%#Eval("LastName") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtLastName" runat="server"
                 Text='<%#Bind("LastName") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtLname" runat="server">
    </asp:TextBox>
    </FooterTemplate>
    </asp:TemplateField>
 
    <asp:TemplateField HeaderText="Department"
                       SortExpression="Department">
    <ItemTemplate>
    <asp:Label ID="lblDepartment" runat="server"
               Text='<%#Eval("Department") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtDepartmentName" runat="server"
                 Text='<%#Bind("Department") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtDept" runat="server">
    </asp:TextBox>
    </FooterTemplate>
    </asp:TemplateField>
 
    <asp:TemplateField HeaderText="Location"
                       SortExpression="Location">
    <ItemTemplate>
    <asp:Label ID="lblLocation" runat="server"
               Text='<%#Eval("Location") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtLocation" runat="server"
                 Text='<%#Bind("Location") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtLoc" runat="server">
    </asp:TextBox>
    </FooterTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBConString%>"
DeleteCommand="DELETE FROM [Employees] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [Employees] ([FirstName],
[LastName],[Department], [Location])
VALUES (@FirstName, @LastName, @Department, @Location)"
SelectCommand="SELECT [ID], [FirstName], [LastName],
[Department], [Location] FROM [Employees]"
UpdateCommand="UPDATE [Employees] SET
[FirstName] = @FirstName, [LastName] = @LastName,
[Department] = @Department, [Location] = @Location
WHERE [ID] = @ID" OnInserted="SqlDataSource1_Inserted">
 
<DeleteParameters>
    <asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="LastName" Type="String" />
    <asp:Parameter Name="Department" Type="String" />
    <asp:Parameter Name="Location" Type="String" />
    <asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="LastName" Type="String" />
    <asp:Parameter Name="Department" Type="String" />
    <asp:Parameter Name="Location" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Label ID="lblMessage" runat="server"
           Font-Bold="True"></asp:Label><br />
 

 

And the error is "it is not a member of 'ASP.default_aspx.'"
I hope you can help me.
Thanks a lot!
Posted 4-May-11 19:53pm
Edited 4-May-11 19:58pm
v2
Comments
S Mewara at 5-May-11 2:15am
   
There must be some event name before the error. What is not the member?
Share the complete error.
bsb25 at 6-May-11 4:41am
   
give the full exception or the error part...we can't help without tat
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Make sure that youre namespaces, classes and events are correctly named. Make sure that you have a GridView1_RowCommand in the code behind class in the right namespace. This is most probably the error.
 
It happens when you rename the name of the class or file and forget to also rename the class or vice versa.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Those are event handlers that don't exist in your code-behind file. You have to add them, and then it should be good to go.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 359
1 Richard MacCutchan 320
2 OriginalGriff 280
3 Jared Sanow 145
4 Snehasish_Nandy 115
0 Sergey Alexandrovich Kryukov 5,939
1 OriginalGriff 4,885
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 6 May 2011
Copyright © CodeProject, 1999-2014
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