错误:它不是"ASP.default_aspx"的成员. [英] ERROR: it is not a member of 'ASP.default_aspx.'

查看:68
本文介绍了错误:它不是"ASP.default_aspx"的成员.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有问题.
我总是有错误.

这是我的代码

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 />







错误是它不是"ASP.default_aspx"的成员."
我希望你能帮助我.
非常感谢!







And the error is "it is not a member of ''ASP.default_aspx.''"
I hope you can help me.
Thanks a lot!

推荐答案

ConnectionStrings:DBConString%> DeleteCommand ="DELETE FROM [Employees] WHERE [ID] = @ID" InsertCommand ="INSERT INTO [Employees]([FirstName], [姓氏],[部门],[位置]) VALUES(@名字,@姓,@部门,@位置)" SelectCommand ="SELECT [ID],[FirstName],[LastName], [部门],[地点]来自[员工] UpdateCommand ="UPDATE [员工]设置 [名字] = @名字,[名字] = @名字, [部门] = @部门,[位置] = @位置 其中[ID] = @ID"OnInserted =" SqlDataSource1_Inserted> < DeleteParameters> < asp:参数名称="ID"类型="Int32"/> </DeleteParameters> < UpdateParameters> < asp:参数名=名字" Type ="String"/> < asp:参数名称=姓氏"类型=字符串"/> < asp:参数名称=部门" Type =字符串"/> < asp:参数名称="Location"类型="String"/> < asp:参数名称="ID"类型="Int32"/> </UpdateParameters> < InsertParameters> < asp:参数名=名字" Type ="String"/> < asp:参数名称=姓氏"类型=字符串"/> < asp:参数名称=部门" Type =字符串"/> < asp:参数名称="Location"类型="String"/> </InsertParameters> </asp:SqlDataSource> < asp:标签ID ="lblMessage" runat =服务器" Font-Bold ="True"></asp:Label>< br/>
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 />







错误是它不是"ASP.default_aspx"的成员."
我希望你能帮助我.
非常感谢!







And the error is "it is not a member of ''ASP.default_aspx.''"
I hope you can help me.
Thanks a lot!


确保正确命名您的命名空间,类和事件.确保正确的名称空间中的类后面的代码中具有GridView1_RowCommand.这很可能是错误.

当您重命名类或文件的名称而忘记同时重命名该类或相反时,也会发生这种情况.
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.


这些是代码隐藏文件中不存在的事件处理程序.您必须添加它们,然后再进行操作就很好.
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.


这篇关于错误:它不是"ASP.default_aspx"的成员.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆