Writing Nested If condition using C# in ASP.Net

Last Reply on Jul 21, 2016 09:52 AM By Shashikant

Posted on Jul 21, 2016 07:45 AM

hi

I use if condition in behind code:

if (Ch3D.Checked == true)
{
    _cmd.Parameters.AddWithValue("@GenrePre", "1");

}
else
{
    if (ChOscar.Checked == true)
    {
        _cmd.Parameters.AddWithValue("@GenrePre", "2");

    }
    else
    {

        if (ChDobleF.Checked == true)
        {
            _cmd.Parameters.AddWithValue("@GenrePre", "3");

        }
    }
}

as you see I used neasted if else condition is there other code that I use it instead of neasted if else contition?

best regards

neda

 

You are viewing reply posted by: nedash on Jul 21, 2016 09:49 AM.
Posted on Jul 21, 2016 09:49 AM

but here maybe users select 2 checkbox i.e:

ch3D and chOscar I want if they select ch3d it doesn't check other checkbox and insert "1" in @Genrepre and if they don't select ch3d after that it checked other condition...