954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Simple DropDownList in DataGridView

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!!!

Corpes
Newbie Poster
6 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

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!

Corpes
Newbie Poster
6 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You