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

[Solved] Problem with cascading dropdown in radgrid

3 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gnanadeep
Top achievements
Rank 1
Gnanadeep asked on 12 Feb 2010, 09:15 AM
Hello,

I need to insert user's details into a table using radgrid.
I need to enter state and country of the user.
So, in Add new record -> I should be able to filter states based on countries using 2 dropdownlists.

So, in the selected index changed event of the country dropdown - i should able to find the both the dropdown controls.
But I am not able to do that. Only null is coming in that.

please, provide me a solution as soon as possible.

Since, I am not saving after selecting country, I suppose the radgrid events may not work in this scenario. I cannot write code in item created or itemdatabound.,, etc.,,..

please check the below image to have an idea... here district and schools are cascading dropdown's
http://i45.tinypic.com/117bdz6.jpg

Thanks in advance,
Gnanadeep

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2010, 11:00 AM
Hi,

In order to find the drop down  on SelectedIndexChanged of another dropdown in the Insert form ,use the NamingContainer as shown below:

C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        GridEditFormInsertItem insertItem = (GridEditFormInsertItem)(sender as DropDownList).NamingContainer; 
        DropDownList ddlList =(DropDownList)insertItem.FindControl("Dropdownlist2"); 
 
    } 


Hope this helps.

Thanks,
Princy
0
Gnanadeep
Top achievements
Rank 1
answered on 12 Feb 2010, 11:38 AM
Thanks for the quick reply..

But using this, EDIT RECORD won't work.
Can you give me a solution that works in both cases.

Any how thanks for the help.

Best Regards,
Gnanadeep
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2010, 05:48 AM
Hi,

You can use the IsItemInserted property to check whether the grid is in insert mode in the dropdownlist SelectedIndexChanged event  as shown  below:

C#
 
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            if (RadGrid1.MasterTableView.IsItemInserted != false
            { 
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)(sender as DropDownList).NamingContainer; 
                DropDownList ddlList = (DropDownList)insertItem.FindControl("Dropdownlist2"); 
            } 
            else 
            { 
                GridEditableItem editedItem = (GridEditableItem)(sender as DropDownList).NamingContainer; 
                DropDownList ddlList = (DropDownList)editedItem.FindControl("Dropdownlist2"); 
            } 
        } 


Hope this helps.

Thanks,
Princy
Tags
Grid
Asked by
Gnanadeep
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Gnanadeep
Top achievements
Rank 1
Share this question
or