TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rushika Jirasinha
NA
1
1.3k
problem with switch case statement
Oct 6 2012 7:45 AM
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;
}
}
Reply
Answers (
1
)
c#.net datagridview control
Set up and Deployment of Application