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

how can i find details table itemtemplate control?

1 Answer 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tamilselvan
Top achievements
Rank 1
Tamilselvan asked on 01 Oct 2010, 03:42 PM
Hi,
  I am using this code, for nested table (Details tables). my sample code for your reference.

    <telerik:RadGrid ID="rgFeedback" runat="server" Width="100%" ShowStatusBar="True"
        AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" PageSize="5"
        Skin="Vista" GridLines="None" OnDetailTableDataBind="rgFeedback_DetailTableDataBind"
        OnItemCommand="rgFeedback_ItemCommand">
        <MasterTableView DataKeyNames="FeedbackQuestionGroupId">
            <DetailTables>
                <telerik:GridTableView ShowHeader="false" DataKeyNames="FeedBackQuestionId" Name="FeedBackQuestion"
                    Width="100%">
                    <Columns>
                        <telerik:GridTemplateColumn UniqueName="AAA1" HeaderText="Question">
                            <ItemTemplate>
                                <asp:Label ID="lbl_Question" Width="50%" Text='<%# Eval("FeedbackQuestionName") %>'
                                    runat="server" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="AAA2">
                            <ItemTemplate>
                                <telerik:RadRating ID="rrRatings" runat="server" ItemCount="10" Precision="Half" Orientation="Horizontal" SelectionMode="Continuous"></telerik:RadRating>                               
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>           
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridTemplateColumn HeaderText="Question Group Name">
                    <ItemTemplate>
                        <asp:Label Width="50%" ID="lblQuestionGroupName1" Text='<% # Eval("QuestionGroupName")%>'
                            runat="server"></asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Rate">
                    <ItemTemplate>
                        <asp:Label Width="5%" ID="lblQuestionGroupName2" runat="server"></asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="SaveQuestionGroup"
                    CommandName="SaveQuestionGroup" ConfirmTitle="CMS asking..." ConfirmText="Save question group details"
                    Text="Save Question Group">
                </telerik:GridButtonColumn>
            </Columns>
            <NoRecordsTemplate>
                <div style="width: 100%; height: 15px; color: Red; text-align: left;">
                    No Records Found.
                </div>
            </NoRecordsTemplate>
        </MasterTableView>
    </telerik:RadGrid>

In ItemCommand event need find the control 'rrRatings' and 'lblQuestionGroupName1' how can i find the value in code behind.
please help me.

Regards,
Tamilselvan.S

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Oct 2010, 07:30 AM
Hello Selvan,

                     I guess you want to access the controls on clicking the ButttonColumn control. If so the following code will help you to access the Label and Rating control from the corresponding row in the "rgFeedback_ItemCommand" event. 

C#.
protected void rgFeedback_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
   {
       if (e.CommandName == "SaveQuestionGroup")
       {
           Label lblParent = (Label)e.Item.FindControl("lblQuestionGroupName1");
           lblParent.Text = "New text";
           GridTableView tableView = (GridTableView)(e.Item as GridDataItem).ChildItem.NestedTableViews[0];
           foreach (GridDataItem item in tableView.Items)
           {
               RadRating rrRatings = (RadRating)item.FindControl("rrRatings");
               int i =Convert.ToInt16( rrRatings.Value);
           }
       }
   }

Regards,
Shinu.
Tags
Grid
Asked by
Tamilselvan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or