Dynamic Dropdown in DataGrid

  • Thread starter Thread starter Niks
  • Start date Start date
N

Niks

Hi,
I have to create a DataGrid which has 5 columns (only for display not
for Edit). Problem is with one column, which displays the database
value if present else it has to display DropDownlist in that column.
How can we do this?

If DropDownList is displayed then, a button has to be displayed in
that row to select the value. My next question is how can we know
which value has been selected in which row ?

Thanks for any ideas,
Niks
 
this exact same question was answered last week. google this news group for
it. i don't have a link. sorry.
 
I searched the entire group and was unable to find the question. Can
you please give me some tips or show me a direction to start with.

Appreciate your help.

Arun.
 
in your itemdatabound event handler you would do something like this
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

dropdownlist ddl = e.item.cells[2]. Controls
if ddl != null
ddl.items.add(new listitem("text","value"));
}

roughly, that would put a dropdown in the third cell each row. this code
will not compile, it is pseudo code. But the idea is correct.
 
Thank you very much, it worked perfect. I did the same thing and
everything is working fine.

Arun.
 
Back
Top