In web application using asp.net, i am using repeater control, in ItmeCommand
event i am trying to find a control using fid control method, i write the code for finding the control it is working fine, when the control is not in repeater control, i am getting exception. How can i handle the exception if the control is not in repeater control. My code is like this :
if (((DropDownList)rpPendingApprovals.Items[i].FindControl "drpBack")).SelectedItem.Value != "0")
when dropdown controls is not there, in repeater then how can i handle this exception help me, thank you.
When you've tried Shoaib's code you are getting exception because if the drodown is not null the second expression is checked which if SelectedItem is null creates the exception so nest the expressions as
var dropdown = (DropDownList)rpPendingApprovals.Items[i].FindControl("drpBack"));
if (dropdown != null && dropdown.SelectedItem != null)
if(dropdown.SelectedValue !="0")
problem hopefully is gone