dropdownlistbox in a datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a dropdownlistbox in a template column of a datagrid. I need to be able to respond to the selecteditemchanged event of the dropdownlist, but I am having trouble doing that. I thought I would be able to use the OnItemCommand event, but that doesn't seem to work. Can someone please point me in the right direction if this can be done?
 
Mike said:
I have a dropdownlistbox in a template column of a datagrid. I need to be able to respond to the selecteditemchanged event of the dropdownlist, but I am having trouble doing that. I thought I would be able to use the OnItemCommand event, but that doesn't seem to work. Can someone please point me in the right direction if this can be done?
 
Hello Mike
I hope this code will help you

public void getSelectedValue()
{
DropDownList dd ;

for(int i = 0; i < dGrid.Items.Count ; i++)
{
dd = new DropDownList();

dd= ((DropDownList)dGrid.Items.FindControl("ddlTrackingBy"));
string b = dGrid.Items.Cells[2].Text;



for(int j = 0 ; j <dd.Items.Count ; j++)
{

if(dd.Items[j].Text == b)

{
dd.SelectedIndex = j;

}

}

}
}

using htis code u could easily get selected index or value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top