anuradha_d wrote:
if (DDlDepartment.SelectedValue != null)
anuradha_d wrote:
else if (DDlDepartment.SelectedValue != null && DDLStaffid.SelectedValue != null)
If you notice the difference between two If statements are of DDLStaffid value. If you
read about If[
^] statement execution then the first condition that is satisfied is executed.
Based on the current implementation, your code would either go into first if or just end of if. Else-If is never going to be executed.
If you really want that condition, then just reverse it. Use the two conditioned if first and then one conditioned.
Hope you got it.
UPDATE:
You definitely need to read on If statements if that was your requirement from start.
Ok. Now, if you want both of them to execute then it can be done in multiple ways. For example
OPTION 1: just separate them!
If(DDlDepartment.SelectedValue != null)
{
}
if (DDlDepartment.SelectedValue != null && DDLStaffid.SelectedValue != null)
{
}
OPTION 2: Cascade the if's
if (DDlDepartment.SelectedValue != null)
{
if (DDLStaffid.SelectedValue != null)
{
}
}
There can be other ways to handle using, other statements. For now, this should do for you.