I want to fill dropdownlist which is inside FormView. I’m writing this code at PageLoad event:
DropDownList ddlTypeOfPayment = dvBooking.FindControl("ddlTypeOfPayment") as DropDownList;
But when I compile itraises the error “Object reference is not set to an instance of object”.
I’m using objectdatasource to bind formview.
How can I do this?
You don’t put it in PageLoad you put it in the
protected void FormView1_DataBound(object sender, EventArgs e)event of your formview.You’ll want to do this instead too: