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

Hirarchy grid Detail table row value finding

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tanuja
Top achievements
Rank 1
Tanuja asked on 27 Sep 2008, 07:38 AM
I am using hirarchy grid in detail table i have check box when i select that check box i need to find all columns in that row. and i want to allow user to check only one record in Detail table records.

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2008, 07:38 AM
Hello Tanuja,

Check out the following code to achieve the required scenario.
aspx:
 <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > 
     <ItemTemplate> 
        <asp:CheckBox ID="CheckBox1"  AutoPostBack="true" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" /> 
     </ItemTemplate> 
 </telerik:GridTemplateColumn> 

cs: (Code to allow only one checkbox checked at a time )
protected void CheckBox1_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox sndrChkbx = (CheckBox)sender; 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                GridTableView nestedView = (GridTableView)item.ChildItem.NestedTableViews[0]; 
               foreach (GridDataItem childItem in nestedView.Items) 
                { 
                    CheckBox chkbx = (CheckBox)childItem["TempCol"].FindControl("CheckBox1"); 
                    chkbx.Checked = false
                } 
            } 
         }        
        sndrChkbx.Checked = true
     } 
 

(code to acess the columns in a row)
 protected void CheckBox2_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox sndrChkbx = (CheckBox)sender; 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                GridTableView nestedView = (GridTableView)item.ChildItem.NestedTableViews[0]; 
                foreach (GridColumn childcolumn in nestedView.Columns) 
                { 
                    foreach (GridDataItem dataItem in nestedView.Items) 
                    { 
                        string strtxt = dataItem[childcolumn.UniqueName].Text; 
                    } 
                } 

Princy.
Tags
Grid
Asked by
Tanuja
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or