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

Getting the value of other cells in the current row

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arno
Top achievements
Rank 2
Arno asked on 20 Oct 2010, 08:42 PM
Hi,

I'm using the loop below to fill a GridDropDownColumn control with items from a customized LINQ query. That part works fine, so I did not include that code.

Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If e.Item.IsInEditMode Then
        For Each Column As GridColumn In e.Item.OwnerTableView.Columns
            If Column.UniqueName = "ProductForReseller" Then
               ' Code goes here
            End If
        Next
    End If
End Sub

To finalize the query, I need to retrieve a value from one of the other cells (a GridDropDownColumn as well) in the same row. It's probably very simple, but I can't find how to get to that value. The HTML is listed below:

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="LinqDataSource1"
            AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" GridLines="None"
            Skin="Outlook" ShowGroupPanel="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True" AutoGenerateColumns="False" Width="62em" Height="37em">
            <ClientSettings AllowDragToGroup="True">
                <Scrolling AllowScroll="True" />
            </ClientSettings>
            <MasterTableView DataKeyNames="reseller, product" EditMode="InPlace" CommandItemDisplay="Bottom"
                DataSourceID="LinqDataSource1">
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="product" SortOrder="Ascending" />
                </SortExpressions>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldName="reseller" HeaderText="Reseller" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="reseller" HeaderText="Reseller" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridEditCommandColumn EditText="edit" HeaderStyle-Width="7em">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridDropDownColumn UniqueName="Reseller" ListTextField="name" ListValueField="id"
                        DataSourceID="LinqDataSourceReseller" HeaderText="Reseller" DataField="reseller"
                        DropDownControlType="RadComboBox" AllowSorting="true" HeaderStyle-Width="7em"
                        AllowFiltering="false">
                    </telerik:GridDropDownColumn>
                    <telerik:GridDropDownColumn UniqueName="ProductForReseller" ListTextField="name" ListValueField="id"
                        DataSourceID="LinqDataSourceProduct" HeaderText="Product" DataField="product"
                        DropDownControlType="RadComboBox" AllowSorting="true" HeaderStyle-Width="7em"
                        AllowFiltering="false">
                    </telerik:GridDropDownColumn>
                    <telerik:GridDropDownColumn UniqueName="ProductActivationType" ListTextField="name"
                        ListValueField="id" DataSourceID="LinqDataSource2" HeaderText="Activation type"
                        DataField="product_activation_type" DropDownControlType="RadComboBox" AllowSorting="true"
                        HeaderStyle-Width="7em" AllowFiltering="false">
                    </telerik:GridDropDownColumn>
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
                        HeaderStyle-Width="7em">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

I want to retrieve the value of the column "Reseller". How can I do it?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Oct 2010, 08:14 AM
Hello ,
 I guess you want to access the value of  RadComboBox (reseller) in edit mode. If so try the following code snippet .

C#:
protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editItem = (GridEditableItem)e.Item;
            RadComboBox rdCombo = (RadComboBox)editItem["Reseller"].Controls[0];
            string value=rdCombo.SelectedValue;
        }
 
 
    }

Thanks,
Princy
0
Arno
Top achievements
Rank 2
answered on 21 Oct 2010, 08:47 AM
Thanks a lot Princy, that's indeed what I needed. It works fine!

Here's the code in VB for anyone else who might need this:
Dim editItem As GridEditableItem = e.Item
Dim rdCombo As RadComboBox = editItem("Reseller").Controls(0)
Dim value As String = rdCombo.SelectedValue
Tags
Grid
Asked by
Arno
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Arno
Top achievements
Rank 2
Share this question
or