I have a Datagrid with 3 DropDownLists in it. Although it is a DataGrid it will really only have two rows. I am populating the BoundColumns using a DataTable in my code.
Normally this is not a problem to setup and create the two rows, hold the two rows of values and retrieve them later. But as it turns out, I have to have different lists in each of my rows
For example:
First Row: — 3 DropDownLists will each have four options: Apples, Oranges, Apples and Oranges, Neither
Second Row: — 3 DropDownLists will each have four options: Grapes, Cherries, Grapes and Cherries, Neither
So I am wondering what is the most painless way to accomplish this. I think a solution has to do with DataSource, and DataTextField and/or DataValueField properties of the DropDownList. But if I put a function in DataSource I am not sure how to pass it the row index so it will know which list to return. Using ItemTypes (Item, AlternatingItem) also might hold a solution but how would they best be used?
Typically, when you need different behavior on different rows, the best route to go is with the
RowDataBoundevent. This event will allow you to inspect the row’s DataItem to conditionally bind any controls in Template columns.