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

Edit GridViewComboBoxColumn

1 Answer 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
TSAN-WEN
Top achievements
Rank 1
TSAN-WEN asked on 17 Jan 2013, 01:39 AM
Dear all,
Recently I use radgridview and gridViewComboBoxColumn to achieve the goal that users could be insert or update database by dropping down the combobox. How can I get the selected-value to operate the database? My codes are listed as below. May you give me some hints? Thank you.

XAML Code:

<telerik:RadGridView x:Name="gv1"

                             Grid.Row="1"

                             Margin="5"

                             AlternationCount="2"

                             AutoGenerateColumns="False"

                             FontSize="{Binding Source={x:Static local:MySettings.Default},

                                                Path=FontSize,

                                                Mode=OneWay}"

                             IsFilteringAllowed="False"

                             SelectionUnit="FullRow"

                             ShowGroupPanel="False"

                             VirtualizingStackPanel.IsVirtualizing="True"

                             VirtualizingStackPanel.VirtualizationMode="Recycling">

            <telerik:RadGridView.Columns>

                <telerik:GridViewDataColumn DataMemberBinding="{Binding opc_id}"

                                            Header="opc_id"

                                            IsReadOnly="False" />

                <telerik:GridViewDataColumn DataMemberBinding="{Binding ip_address}"

                                            Header="ip_address"

                                            IsReadOnly="False" />

                <telerik:GridViewDataColumn DataMemberBinding="{Binding hmi_user}"

                                            Header="hmi_user"

                                            IsReadOnly="False" />

                <telerik:GridViewDataColumn DataMemberBinding="{Binding description}"

                                            Header="description"

                                            IsReadOnly="False" />

 

                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding entry_area}"

                                                DisplayMemberPath="description"

                                                Header="entry_area"

                                                IsReadOnly="False"

                                                SelectedValueMemberPath="Id"

                                                UniqueName="entry_area" />

 

            </telerik:RadGridView.Columns>

        </telerik:RadGridView>"

 

 

VB.NET CODE:

 

Private Sub gv1_RowEditEnded(sender As Object, e As Telerik.Windows.Controls.GridViewRowEditEndedEventArgs) Handles gv1.RowEditEnded

        If e.EditAction = GridViewEditAction.Cancel Then

            Exit Sub

        End If

 

        If e.EditOperationType = GridViewEditOperationType.Insert Then

            'Add the new entry to the data base.

 

            Dim opc As New OPC_Profile With {.opc_id = TryCast(e.Row.Cells(0).Content, TextBlock).Text, _

                                 .ip_address = TryCast(e.Row.Cells(1).Content, TextBlock).Text, _

                                 .hmi_user = TryCast(e.Row.Cells(2).Content, TextBlock).Text, _

                                 .description = TryCast(e.Row.Cells(3).Content, TextBlock).Text, _

                                 .entry_area = TryCast(e.Row.Cells(4).Content, LookupElement).ComboBox.Text}

        End If

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 21 Jan 2013, 11:20 AM
Hi,

I have already answered your ticket containing the same question. However, I will post my answer here as well in case anyone experience the same behavior:

In order to achieve your goal, I can suggest you to check this forum thread where a similar topic has been discussed. However, I have prepared a sample project which you can find attached.


Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
TSAN-WEN
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or