views:

42

answers:

1

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?

A: 

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:

dvBooking.Row.FindControl("ddlTypeOfPayment");
Graphain
Available events of FormView are DataBound and ItemCreated. I've checked on both but same problem
hotcoder
I've changed to this but still same error
hotcoder