I'm trying to insert values into dropdownlist that placed in datagridview - itemtemplate dynamically.
I'v typed:

DropDownList dd=(DropDownList)gridViewRowVar.FindControl("techniciansDDL");
dd.Items.Add("ddd");

and there's a problem: System.NullReferenceException was unhandled by user code, and something like:
The reference to the object had not been classified to the event of the object.
The error is just on runtime,
icant understand why its so complicated to insert a simpal information into ddl. plz help~!

Tell me if i wasnt clear!!!

I solved it!
To whom it may concern:
The DropDownList has a property called: DataSource.
In this property put a name of a function, like: BindData()
Go to the __.aspx.cs, build this function that'll have returned a DataSet/DataTable/String. DataTable is the best. Now back to ur DropDownList, and in the property of: DataTextField type the column in the datatable u want to be display. thas it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.