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

Different data source for different Combobox rows

3 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 09 Sep 2011, 10:57 PM
I have a grid view in which I want to customize the combobox entries for a given row depending on user selection of another combobox entry in the row.  Different rows would have different data sources.  Is this possible, and if so, can you tell me how to do it? 

Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 12 Sep 2011, 06:59 AM
Hello Claude,

Please handle the CellEditorInitialized event and set the data source for the RadDropDownListEditorElement, like so:
 
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (e.Row is GridViewNewRowInfo)
    {
        if (e.ColumnIndex == 0)
        {
            var editor = e.ActiveEditor as RadDropDownListEditor;
            if (editor == null)
            {
                return;
            }
  
            var editorElement = editor.EditorElement as RadDropDownListEditorElement;
            editorElement.DataSource= someOtherDataSource;
        }
    }
}

Best Regards,
Emanuel Varga
0
Ivan Petrov
Telerik team
answered on 14 Sep 2011, 04:32 PM
Emanuel, thank you for the provided solution.

Claude, the approch that Emanuel has provided is the right way to go in this situation. Please remember to mark his post as an answer, so that others can easily find it if they have the same question like you did.

If you need further help, do not hesitate to write again. We will do our best to help you. 

Greetings,
Ivan Petrov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Claude
Top achievements
Rank 1
answered on 15 Sep 2011, 02:14 AM
I didn't have a chance to test his solution until now.  It worked fine.
Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Ivan Petrov
Telerik team
Claude
Top achievements
Rank 1
Share this question
or