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

RadGrid Row + Multiple DropDownLists, where 2nd + 3rd's datasource are dependant on selected value of first dropdown.

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 28 Sep 2008, 03:09 PM
Hi

I need to determine in the SelectedItemChange event of the first dropdownlist in a rad grid row, the parameters to pass to the 2nd and 3rd dropdownlists for them to  databind.
Note: This in insert mode (AddNew record) , and no Records loaded i.e.  Blank Table,...and trying to create the new record.

So, how do I reference these other dropdownlists per that Grid Row" .....I don't have the   GridEditableItem param in the drop downs param
Typically I woud expect something like
DropDownList  my1stDropDown = Grid1.EditedRow,FindCZontrol(1stDropDown) as DropDownList;
string SelVal = my1stDropDown .SelectedValue;

DropDownList  my2ndDropDown = Grid1.EditedRow,FindCZontrol(2ndDropDown) as DropDownList;
my2ndDropDown.DataSource = SomeDSource;
etc


TIA
Neal

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2008, 05:18 AM
Hello Neal,

You can try out the following code to access other dropdownlists in the InsertForm on the SelectedIndexChanged event of the one dropdownlist.
cs:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        DropDownList ddList1 = (DropDownList)sender; 
        GridEditFormInsertItem insertItem = (GridEditFormInsertItem)ddList1.NamingContainer; 
        DropDownList ddList2 = (DropDownList)insertItem.FindControl("DropDownList2"); 
        //bind ddList2 to the data source with custom code here 
        ... 
    } 

Thanks
Princy.
0
Neal
Top achievements
Rank 1
answered on 29 Sep 2008, 08:48 AM
Hi Thanks Princy,

Will give it a go,...my worry was that this is, on the first i.e. to be created row whilst in "insert mode of the Grid"..null reference exceptions.

If any hassles will reply asap.

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