BOEING39
asked on
REQUIRE ASSISTANCE WITH LABEL CODE BEHIND
Please review the attached code for "Label1" which is driving the following error. I need assistance in with the code behind.
Compiler Error Message: CS0111: Type 'Inspection' already defines a member called 'Page_Load' with the same parameter types
Source Error:
Line 86:
Line 87:
Line 88: protected void Page_Load(object sender, EventArgs e)
Line 89: {
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
Code:
partial class Inspection : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
SqlConnection con = new SqlConnection("");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDropdown(CondBY);
FillDropdown(InspBy1);
}
}
//Filldrop down
void FillDropdown(DropDownList ddl)
{
SqlConnection con = new SqlConnection("");//connec tion string;
con.Open();
SqlCommand cmd = new SqlCommand("select * from EmpData", con);
SqlDataAdapter dap = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
ddl.DataSource = ds;
ddl.DataTextField = "Name1";//Database table filed name for display in dropdown
ddl.DataValueField = "EmpNo";//display in textbox when select dropdown field
ddl.DataBind();
}
protected void CondBY_SelectedIndexChange d(object sender, EventArgs e)
{
EmpAP.Text = CondBY.SelectedValue.ToStr ing();// get value form dropdown
}
protected void InspBy1_SelectedIndexChang ed(object sender, EventArgs e)
{
EmpAP1.Text = InspBy1.SelectedValue.ToSt ring();// get value form dropdown
}
protected void Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
{
if (CondBY.SelectedValue == "CONMX" && Conmx.Text == "")
{
Label1.Visible = true;
Label1.Text = "Enter Name";
}
}
}
}
Compiler Error Message: CS0111: Type 'Inspection' already defines a member called 'Page_Load' with the same parameter types
Source Error:
Line 86:
Line 87:
Line 88: protected void Page_Load(object sender, EventArgs e)
Line 89: {
--------------------------
Code:
partial class Inspection : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
SqlConnection con = new SqlConnection("");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDropdown(CondBY);
FillDropdown(InspBy1);
}
}
//Filldrop down
void FillDropdown(DropDownList ddl)
{
SqlConnection con = new SqlConnection("");//connec
con.Open();
SqlCommand cmd = new SqlCommand("select * from EmpData", con);
SqlDataAdapter dap = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
ddl.DataSource = ds;
ddl.DataTextField = "Name1";//Database table filed name for display in dropdown
ddl.DataValueField = "EmpNo";//display in textbox when select dropdown field
ddl.DataBind();
}
protected void CondBY_SelectedIndexChange
{
EmpAP.Text = CondBY.SelectedValue.ToStr
}
protected void InspBy1_SelectedIndexChang
{
EmpAP1.Text = InspBy1.SelectedValue.ToSt
}
protected void Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
{
if (CondBY.SelectedValue == "CONMX" && Conmx.Text == "")
{
Label1.Visible = true;
Label1.Text = "Enter Name";
}
}
}
}
Can you check your code since this error means that you have two protected void Page_Load?
ASKER
Yes that is the error I need assistance getting around this. When "CONMX" is selected under the "ConBY" ddl I need "Label1" to display. I am not sure of the code behind arrangement. I am now receiving this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0542: 'Inspection': member names cannot be the same as their enclosing type
Source Error:
Line 71: }
Line 72:
Line 73: partial class Inspection : System.Web.UI.Page
Line 74:
Line 75: {
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
CODE
protected void InspBy1_SelectedIndexChang ed(object sender, EventArgs e)
{
EmpAP1.Text = InspBy1.SelectedValue.ToSt ring();// get value form dropdown
}
partial class Inspection : System.Web.UI.Page
{
}
protected void Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
{
if (CondBY.SelectedValue == "CONMX" && Conmx.Text == "")
{
Label1.Visible = true;
Label1.Text = "Enter Name";
}
}
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0542: 'Inspection': member names cannot be the same as their enclosing type
Source Error:
Line 71: }
Line 72:
Line 73: partial class Inspection : System.Web.UI.Page
Line 74:
Line 75: {
--------------------------
CODE
protected void InspBy1_SelectedIndexChang
{
EmpAP1.Text = InspBy1.SelectedValue.ToSt
}
partial class Inspection : System.Web.UI.Page
{
}
protected void Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
{
if (CondBY.SelectedValue == "CONMX" && Conmx.Text == "")
{
Label1.Visible = true;
Label1.Text = "Enter Name";
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked. Thx