This is a migrated thread and some comments may be shown as answers.

Retrieve value of changed dropdown

3 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 15 Sep 2008, 06:28 PM
I have a grid edit form.
In this form, I have a dropdown list of packages. Based on this list, 
I embed a grid of the items in a particular package.

I want a user to select a package the dropdown from the list, and without clicking ok,
the embedded grid should re-populate.

I do not see what is getting fired when the user changes the packages field in
the dropdown list. I have Onselectedindexchanged but my debugger
does not go into it when the dropdown is changed.

What am I missing?

Thanks,
Laura


3 Answers, 1 is accepted

Sort by
0
Jack
Top achievements
Rank 1
answered on 16 Sep 2008, 04:02 AM
Try like this..change the columns names and grid names as requried

protected void GridName_ItemCreated(object sender, GridItemEventArgs e)
    {
GridEditableItem edititem = (GridEditableItem)e.Item;

          
            RadComboBox ddl1 = (RadComboBox)edititem["columnname"].Controls[0];

            //attach SelectedIndexChanged event for the combobox control
            ddl1 .AutoPostBack = true;
            ddl1 .SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(ddl1 _SelectedIndexChanged);
        }

void ddl1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        //first reference the edited grid item through the NamingContainer attribute
        GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;

   (editedItem["columnname"].Controls[0] as RadComboBox).SelectedItem.Text;
}

0
Princy
Top achievements
Rank 2
answered on 16 Sep 2008, 10:55 AM
Hi,

Try the code to update the  embedded grid in the edit form on the selected index changed evnet of the dropdownlist.

public void  DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
         GridEditableItem editedItem = (sender as DropDownList1).NamingContainer as GridEditableItem; 
        DropDownList ddl=(DropDownList)sender; 
       if(ddl.SelectedItem.Text=="Package1") 
        (editedItem.FindControl("RadGrid1")  as RadGrid).MasterTableview.Rebind(); 
 



Thanks,
Princy
0
Laura
Top achievements
Rank 1
answered on 17 Sep 2008, 12:39 AM
Thank you


Tags
Grid
Asked by
Laura
Top achievements
Rank 1
Answers by
Jack
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Laura
Top achievements
Rank 1
Share this question
or