Datagrid ItemCommand Fall Through??

B

Brian Conway

I am getting the following error on this statement (Control cannot fall
through from one case label to another). Anyone heard this before?

private void DataGrid1_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

switch(e.CommandName)

{

case "FindCUID":


string vdgCUID;

Fleet.LDAP.AuthenticationServices User = new
Fleet.LDAP.AuthenticationServices();

DataSet dsCUID = new DataSet();

dsCUID = User.getUserInfo((string)e.Item.Cells[5].Text);

Label1.Text = vdgCUID;

e.Item.Cells[8].Text = (string)dsCUID.Tables[0].Rows[0]["sn"];//matches
dataset fields with textbox.

e.Item.Cells[7].Text = (string)dsCUID.Tables[0].Rows[0]["givenname"];


case "More":


Session["xUnit"] = e.Item.Cells[1].Text;

Session["xrcCode"] = e.Item.Cells[2].Text;

Session["xLastOdo"] = e.Item.Cells[3].Text;

Session["xDriver"] = e.Item.Cells[5].Text;

Session["xFirstName"] = e.Item.Cells[6].Text;

Session["xLastName"] = e.Item.Cells[7].Text;

Session["xLocation"] = e.Item.Cells[8].Text;

Session["xHome"] = e.Item.Cells[9].Text;

Server.Transfer("ChangeForm.aspx", true);

string sUrl = "ChangeForm.aspx";

string sFeatures = "'height=600;width=400;left=100;top=50;'";

string sScript;

sScript = "<script language=javascript>" +

"window.open('" + sUrl + "',''," + sFeatures + ");"+

"</script>";

// Write it into the output stream for immediate execution

Response.Write(sScript);} }
 
S

Simon Smith

I am getting the following error on this statement (Control cannot fall
through from one case label to another). Anyone heard this before?

Yes. The switch statement in C# does not support fall-through[1] and enforces
that by making you put something which will force the flow of control out
of the switch at the end of one case and before the next:
switch (a) {
case 1:
a++;
break; // <== must have
case 2:
a--;
return; // <== OK too
case 3:
a = a + b; // oh oh!
case 4: // can fall through as 4 and 5 are the same case
case 5: // [1] above
a = a - b;
throw new Exception("Just to show you can"); // This'll be OK too
}
 
A

Adam Clauss

You can "sort of" simulate fallthrough using the goto command.

switch (x)
{
case 0: a = a+b;
goto case 1;
case 1: a = a*b;
break;
default:
break;
}

In this example, if x==0, then a would get increased by b, and then multiplied by b.

HTH
--
Adam Clauss
(e-mail address removed)
Simon Smith said:
I am getting the following error on this statement (Control cannot fall
through from one case label to another). Anyone heard this before?

Yes. The switch statement in C# does not support fall-through[1] and enforces
that by making you put something which will force the flow of control out
of the switch at the end of one case and before the next:
switch (a) {
case 1:
a++;
break; // <== must have
case 2:
a--;
return; // <== OK too
case 3:
a = a + b; // oh oh!
case 4: // can fall through as 4 and 5 are the same case
case 5: // [1] above
a = a - b;
throw new Exception("Just to show you can"); // This'll be OK too
}
 
S

Simon Smith

You can "sort of" simulate fallthrough using the goto command.

switch (x)
{
case 0: a = a+b;
goto case 1;
case 1: a = a*b;
break;
default:
break;
}

In this example, if x==0, then a would get increased by b, and then multiplied
by b.

HTH

Yep - but I never use it so I didn't mention it :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

HELP Please on Code 1
This takes forever!!!!!!!! 1

Top