Hey,
I have been working on a project where I have to disable certain menu items according to user level in the load event. For that first I retrieve database info as form name (BA,BB etc.) and value (true/false) columns to a datagrid. The form name is assigned to variable formName .If value = true the relevant form is enabled.
My problem is after geting the formName the switch statement doesn't get executed. But when string formName = "BA"; is given manually it goes inside the switch. I tried with if statement and got the same problem. Please help me out with this.I tried a lot but coudn't find the error.
Thanks in advance.
Rushika
for (int i = 0; i < dt.Rows.Count; i++)
{
if (Boolean.Parse(dt.Rows[i][1].ToString()) == true) //if true enable relevant form
{
string formName = dt.Rows[i][0].ToString(); // doesn't work
// string formName = "BA"; works this way
switch (formName) // doesn't go inside the switch
{
case "BA":
BA.Enabled = true;
break;
}
}