I
Iain
Hi All
I have the code below (Using Delphi 2006 Developer to create an C#
ASP.Net page to update a simple database table. When the page is fired
I get the following error message
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Compiler Error Message: CS0122:
'LivLeadTime.WebForm2.Livery_DeleteCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' is inaccessible
due to its protection level
Source Error:
Line 17:
Line 18: <div align="center">
Line 19: <asp:datagrid
Line 20: id="Livery"
Line 21: runat="server"
Source File: c:\inetpub\wwwroot\LivLeadTime\WebForm2.aspx Line: 19
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As I am new to C# (or any C type language) I am finding this hard to
understand. Can anyone tell me what is wrong with this piece of code.
The code is below
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The WebForm2.aspx definitions for the form are
<asp:datagrid
id="Livery"
runat="server"
width="92%"
cellpadding="5"
font-size="8pt"
ondeletecommand="Livery_DeleteCommand"
autogeneratecolumns="false"
headerstyle-backcolor="black"
headerstyle-forecolor="white"
headerstyle-font-bold="true"
itemstyle-verticalalign="top"
oncancelcommand="Livery_CancelCommand"
onupdatecommand="Livery_UpdateCommand"
oneditcommand="Livery_EditCommand"
allowsorting="True"
onsortcommand="Livery_SortCommand">
<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0"></EditItemStyle>
<ItemStyle verticalalign="Top"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Black"></HeaderStyle>
<Columns>
<asp:EditCommandColumn
HeaderText="Edit"
EditText="Edit"
ButtonType="PushButton"
CancelText="Cancel"
UpdateText="Update">
</asp:EditCommandColumn>
<ASP:BoundColumn
datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn
datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<asp:buttoncolumn
Text="Delete"
HeaderText="Delete"
ButtonType="PushButton"
CommandName="Delete">
</asp:buttoncolumn>
</Columns>
</asp:datagrid>
and the WebForm2.aspx.cs code is as follows
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace LivLeadTime
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Livery;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((! IsPostBack))
{
}
else
{
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Livery.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_CancelCommand);
this.Livery.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_EditCommand);
this.Livery.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.Livery_SortCommand);
this.Livery.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_UpdateCommand);
this.Livery.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_DeleteCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Livery_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Editing";
}
private void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Deleting";
}
private void Livery_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string LString = "Sorting";
}
private void Livery_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Updating";
}
private void Livery_CancelCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Cancelling";
}
}
I have the code below (Using Delphi 2006 Developer to create an C#
ASP.Net page to update a simple database table. When the page is fired
I get the following error message
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Compiler Error Message: CS0122:
'LivLeadTime.WebForm2.Livery_DeleteCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' is inaccessible
due to its protection level
Source Error:
Line 17:
Line 18: <div align="center">
Line 19: <asp:datagrid
Line 20: id="Livery"
Line 21: runat="server"
Source File: c:\inetpub\wwwroot\LivLeadTime\WebForm2.aspx Line: 19
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As I am new to C# (or any C type language) I am finding this hard to
understand. Can anyone tell me what is wrong with this piece of code.
The code is below
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The WebForm2.aspx definitions for the form are
<asp:datagrid
id="Livery"
runat="server"
width="92%"
cellpadding="5"
font-size="8pt"
ondeletecommand="Livery_DeleteCommand"
autogeneratecolumns="false"
headerstyle-backcolor="black"
headerstyle-forecolor="white"
headerstyle-font-bold="true"
itemstyle-verticalalign="top"
oncancelcommand="Livery_CancelCommand"
onupdatecommand="Livery_UpdateCommand"
oneditcommand="Livery_EditCommand"
allowsorting="True"
onsortcommand="Livery_SortCommand">
<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0"></EditItemStyle>
<ItemStyle verticalalign="Top"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Black"></HeaderStyle>
<Columns>
<asp:EditCommandColumn
HeaderText="Edit"
EditText="Edit"
ButtonType="PushButton"
CancelText="Cancel"
UpdateText="Update">
</asp:EditCommandColumn>
<ASP:BoundColumn
datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn
datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<asp:buttoncolumn
Text="Delete"
HeaderText="Delete"
ButtonType="PushButton"
CommandName="Delete">
</asp:buttoncolumn>
</Columns>
</asp:datagrid>
and the WebForm2.aspx.cs code is as follows
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace LivLeadTime
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Livery;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((! IsPostBack))
{
}
else
{
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Livery.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_CancelCommand);
this.Livery.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_EditCommand);
this.Livery.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.Livery_SortCommand);
this.Livery.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_UpdateCommand);
this.Livery.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.Livery_DeleteCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Livery_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Editing";
}
private void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Deleting";
}
private void Livery_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string LString = "Sorting";
}
private void Livery_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Updating";
}
private void Livery_CancelCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Cancelling";
}
}