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

How to retrive GridViewComboBoxColumn ID

4 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nag
Top achievements
Rank 1
Nag asked on 21 Dec 2010, 03:00 PM
Hi folks,
               I done the gridviewcombobox data binded in Radgridview control,But I cannot able to retrive the GridviewComboBox column ID in radgrid control.
           
 Here is my xaml code:

    <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" RowEditEnded="RadGridView1_RowEditEnded" BeginningEdit="RadGridView1_BeginningEdit">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}">
                </telerik:GridViewDataColumn>

                <telerik:GridViewComboBoxColumn Header="Nationality"                       
                                                IsComboBoxEditable="True"
                                                ItemsSource="{Binding Countries, Source={StaticResource CountriesSource}}"
                                                DataMemberBinding="{Binding CountryID, Mode=TwoWay}"
                                                DisplayMemberPath="Name"
                                                SelectedValueMemberPath="ID">
                    <telerik:GridViewComboBoxColumn.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}"></TextBlock>
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.ItemTemplate>
                </telerik:GridViewComboBoxColumn>
                           
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

Please find out the below attachment for your reference.

  Please tell me as soon as possible. Advance thanks

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Dec 2010, 03:11 PM
Hello Nag,

In order to provide you with an accurate solution I would need a bit more details about you exact requirement. Do you need to retrieve the id of the column - its index ? In this case you can use the DisplayIndex property of the column. Or you need to get the value of the ID property in the ItemsSource of the GridViewComboBoxColumn ? - In this case you can retrieve the CountryID value - it corresponds to the ID or get the SelectedItem for example of the ComboBox.

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Nag
Top achievements
Rank 1
answered on 21 Dec 2010, 03:28 PM
Hello Maya ,
                           Thanks for your reply, I need the ComboBox selected id value in Radgridview1 control. Here i am getting the text value according to below code. Please refer this code.


 private void RadGridView1_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
         
            GridViewComboBoxColumn column = new GridViewComboBoxColumn();
         
             string id = (this.RadGridView1.CurrentCell.Value.ToString());

        }

Thanks in advance.
0
Accepted
Maya
Telerik team
answered on 22 Dec 2010, 08:58 AM
Hello Nag,

Firstly, there is no need to create a new GridViewComboBoxColumn as you already have it in the definition of the grid. In the way you handle the event, you will have a new instance of the column, but not the one you need. Furthermore, RowEditEnded event is not an appropriate place for creating a new column.
The easiest way to get the countryID of the selected item is to get the id of the edited item as in this case they are equal. So, you may handle the RowEditEnded event as follows:

void RadGridView1_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
    var id = (e.EditedItem as Person).CountryID;
}


All the best,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Nag
Top achievements
Rank 1
answered on 23 Dec 2010, 06:11 AM
Hi Maya,
                    It's working good, Thank you very much.


Tags
General Discussions
Asked by
Nag
Top achievements
Rank 1
Answers by
Maya
Telerik team
Nag
Top achievements
Rank 1
Share this question
or