日期:2014-05-18  浏览次数:20419 次

请教错误处理:不可访问,因为它受保护级别限制
问题代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DepartmentsAdmin.ascx.cs" Inherits="AdminUserControls_DepartmentsAdmin" %>
<asp:GridView ID="departmentsGrid" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="departmentsGrid_SelectedIndexChanged" Width="100%">
  <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
  <Columns>
  <asp:BoundField DataField="Name" HeaderText="Department Name" />
  <asp:TemplateField HeaderText="Department Description">
  <EditItemTemplate>
  <asp:TextBox ID="editDescriptionTextBox" runat="server" Rows="3" Text='<%# Bind("Description") %>'
  TextMode="MultiLine" Width="100%"></asp:TextBox>
  </EditItemTemplate>
  <ItemTemplate>
  <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
  </ItemTemplate>
  </asp:TemplateField>
  <asp:CommandField ButtonType="Button" EditText="Edit" ShowEditButton="True" />
  <asp:CommandField ButtonType="Button" SelectText="Edit Categories" ShowSelectButton="True" />
  <asp:CommandField ButtonType="Button" DeleteText="delete" ShowDeleteButton="True" />
  </Columns>
  <RowStyle BackColor="#E3EAEB" />
  <EditRowStyle BackColor="#7C6F57" />
  <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
  <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
  <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
  <AlternatingRowStyle BackColor="White" />
</asp:GridView>
<br />
<asp:Label ID="Label1" runat="server" Text="Add new department:"></asp:Label>
<asp:TextBox ID="nameTextBox" runat="server">(departname)</asp:TextBox>
<asp:TextBox ID="descriptionTextBox" runat="server">(department desription)</asp:TextBox>
<asp:Button ID="addDepartmentButton" runat="server" Text="Add" /><br />

错误提示:
错误 2 “AdminUserControls_DepartmentsAdmin.departmentsGrid_SelectedIndexChanged(object, System.EventArgs)”不可访问,因为它受保护级别限制 D:\MyCommerceSite\JokePoint\AdminUserControls\DepartmentsAdmin.ascx 2


------解决方案--------------------
在CS页面中看看
................... += departmentsGrid_SelectedIndexChanged(object, System.EventArgs)前面的修饰符改为protected
------解决方案--------------------
AdminUserControls_DepartmentsAdmin.departmentsGrid_SelectedIndexChanged(object, System.EventArgs)

必须是protected或者public的,private有保护级别限制问题