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

Selected Row values of DetailTable View

6 Answers 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
waseem
Top achievements
Rank 2
waseem asked on 20 Feb 2010, 09:54 AM
Dear,

I am trying to get the selected row values of the DetailTable View.

 

 

<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn"></telerik:GridClientSelectColumn>

 


GridClient Select Column is in DetailTable. 

I need to get the values of each column of selected Row in DetailTable View when i pressed the Button "Procced with Selected Rows"

Regards,

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Feb 2010, 11:19 AM
Hello Waseem,

You can traverse through the items in the grid and check for the item.OwnerTableView.Name whether it is DetailTable Name and get the corresponding values.

The following help documentation shows how to achieve this.
Traversing detail tables/items in Telerik RadGrid

-Shinu.
0
waseem
Top achievements
Rank 2
answered on 20 Feb 2010, 03:28 PM

Dear,

i need to access the columns values. please can you check my code.

 
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
 

For Each item As GridDataItem In RadGrid1.Items
 

If item.OwnerTableView.Name = "Rooms" Then
 

  If item.Selected = True Then
 
   txtValues.Text &= item.OwnerTableView.DataKeyValues(item.ItemIndex)("HotelCode").ToString
 
   Dim DT As GridDataItem = item.OwnerTableView.Items(item.ItemIndex)
 

   txtValues.Text = DT("RoomtypeCode").Text
 

  End If
 
 End If
 
Next

End Sub

There are four others Column i have to acces their values.

 

   Dim DT As GridDataItem = item.OwnerTableView.Items(item.ItemIndex)
 

   txtValues.Text = DT("RoomtypeCode").Text  

above code is noting returning......

0
Princy
Top achievements
Rank 2
answered on 22 Feb 2010, 05:25 AM
Hi,

You should be able to access the row values of the DetailTable directly using the item object as shown below:
In this scenario I have a MasterTable  and a child table.

C#
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.OwnerTableView.Name == "Detail"
            { 
                if(item.Selected) 
                { 
                  string str = item["ColumnUniqueName"].Text; 
                } 
            } 
        } 
    } 


Thanks,
Princy
0
waseem
Top achievements
Rank 2
answered on 22 Feb 2010, 08:52 AM
Dear,

first of all I try this code but nothign is working, it return "" (emptry string value).

This is Child Table Coding

<columns>

<telerik:GridBoundColumn UniqueName="RTypeCode" DataField="RoomTypeCode" Visible="false"></telerik:GridBoundColumn>
</columns>

<itemTemplate>
        <%#DataBinder.Eval(Container.DataItem, "RoomType")%>

</itemTemplate>

 

 

For Each item As GridDataItem In RadGrid1.Items

    If item.OwnerTableView.Name = "Rooms" Then

        If item.Selected Then

            Dim str As String = item("RTypeCode").Text

            RadAjaxManager1.Alert(str)

        End If

    End If

Next

*
|---Master
|----------- Child (selected value)
on same level i need to get the parent values as well of the selected row.

 

 

 
************ Extra Information *****************
Right now i m getting values throuh "ClientDataKeyNames" 

 <telerik:GridTableView Name="Rooms" ClientDataKeyNames="HotelCode,RoomTypeCode,RoomType,RoomBasis,cancellation,Total" DataKeyNames="HotelCode" runat="server" BorderStyle="None">
                                                                       
                                                                            <Columns>
                                                                           
                                                                                <telerik:GridBoundColumn DataField="HotelCode" Visible="false"></telerik:GridBoundColumn>
                                                                                <telerik:GridBoundColumn UniqueName="RTypeCode" DataField="RoomTypeCode" Visible="false"></telerik:GridBoundColumn>
                                                                                <telerik:GridBoundColumn DataField="cancellation" Visible="false"></telerik:GridBoundColumn>
                                                                               
                                                                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" Visible="true"></telerik:GridClientSelectColumn>
                                                                            
                                                                                                                                                    
                                                                            </Columns>
                                                                            <ItemTemplate>
                                                                                <table cellpadding="0" cellspacing="0" width="100%" style="border-style:solid; border-width:1px; border-color:#E4B93C">
                                                                               
                                                                                    <tr>
                                                                                       
                                                                                        <td width="150" style="height:20px"><span class="Font8Gray"><%#DataBinder.Eval(Container.DataItem, "RoomType")%></span></td>
                                                                                        <td width="5" style="height:20px"></td>
                                                                                        <td width="100" style="height:20px"><span class="Font8Gray"><%#DataBinder.Eval(Container.DataItem, "RoomBasis")%></span></td>
                                                                                        <td width="5"></td>
                                                                                        <td width="100" style="height:20px"><span class="Font8Gray"><%#DataBinder.Eval(Container.DataItem, "Total")%></span></td>
                                                                                        <td width="50" style="height:20px">
                                                                                            <asp:HyperLink ID="hypBook" runat="server" Text="Book" NavigateUrl="Booknow.aspx?CodeID" CssClass="link1"></asp:HyperLink>
                                                                                        </td>
                                                                                       
                                                                                    </tr>
                                                                                   
                                                                                    <tr>
                                                                                        <td colspan="6"><asp:Label ID="lblSpecialDeals" CssClass="Font8White" runat="server" Visible="true" Text='<%#DataBinder.Eval(Container.DataItem,"SpecialDeal") %>'></asp:Label></td>
                                                                                    </tr>
                                                                                  
                                                                                </table>
                                                                            </ItemTemplate>
                                                                           
                                                                           
                                                                           
                                                                           
                                                                        </telerik:GridTableView>


********************************* End here *************************

0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Feb 2010, 06:34 AM
Hi Waseem,

As you have set  the column RTypeCode  to Visisble False you will not be able to access it i .A suggestion would be to set it to Display False instead of Visible.

Hope this helps.

Thanks,
Princy
0
waseem
Top achievements
Rank 2
answered on 01 Mar 2010, 07:24 AM
Dear Princy,

Thank you its Work..............
Tags
Grid
Asked by
waseem
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
waseem
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or