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

CheckBox OnCheckChanged Event within a Grid

7 Answers 710 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 26 Nov 2008, 04:22 PM
Hi,
I have a number of checkboxes within a grid. The state of these checkboxes change the enabled state of other columns within the grid when in edit mode.
 
<telerik:RadGrid ID="RadGrid1" 
                     Skin="Vista"   
                     runat="server"   
                     Width="1050"   
                     GridLines="None" 
                     AllowAutomaticInserts="false" 
                     AutoGenerateColumns="False" 
                     AllowMultiRowSelection="False"   
                     AllowSorting="False"   
                     AllowPaging="False" 
                     OnItemCommand="RadGrid1_ItemCommand"   
                     OnItemCreated="RadGrid1_ItemCreated" 
                     OnUpdateCommand="RadGrid1_UpdateCommand"   
                     OnNeedDataSource="RadGrid1_NeedDataSource" 
                     OnItemDataBound="RadGrid1_ItemDataBound"   
                     ShowStatusBar="true"   
                     OnDeleteCommand="RadGrid1_DeleteCommand">  
            <PagerStyle Mode="NumericPages"></PagerStyle> 
            <MasterTableView DataKeyNames="Id" AllowMultiColumnSorting="True" EditMode="InPlace" CommandItemStyle-Height="28px" CommandItemDisplay="Top">  
            <CommandItemTemplate> 
                      <table style="width:100%">  
                        <tr> 
                            <td> 
                                <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Edit.gif" />Edit selected route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Update.gif" />Update</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Cancel.gif" />Cancel editing</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnInitInsert" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/AddRecord.gif" />Add new route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnInsert" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Insert.gif" /> Add route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnDeleteSelected" runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Delete.gif" />Delete selected route</asp:LinkButton>&nbsp;&nbsp;  
                            </td> 
                            <td style="text-align:right;"><asp:LinkButton ID="btnRefresh" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Refresh.gif" />Refresh</asp:LinkButton></td>  
                        </tr> 
                    </table>       
            </CommandItemTemplate> 
            <Columns> 
                <telerik:GridBoundColumn UniqueName="Id" DataField="Id" ReadOnly="true" Visible="false" /> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" ItemStyle-Width="30px" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Panel ID="Panel1" runat="server">  
                            <asp:CheckBox ID="Enabled" runat="server" AutoPostBack="true" Checked='<%# Eval("Enabled") %>' OnCheckedChanged="EnabledChanged" /> 
                        </asp:Panel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" ItemStyle-Width="50px" HeaderText="Metabolite" HeaderStyle-HorizontalAlign="Center">  
                    <ItemTemplate> 
                        <asp:Panel ID="Panel2" runat="server" HorizontalAlign="Center">  
                            <asp:CheckBox ID="Metabolite" runat="server" AutoPostBack="true" Checked='<%# Eval("Metabolite") %>' /> 
                        </asp:Panel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridDropDownColumn UniqueName="Pathway" ItemStyle-Width="170px" ListTextField="PathwayName" ListValueField="Pathway" ListDataMember="Pathways" DataField="Pathway" HeaderStyle-HorizontalAlign="Left" HeaderText="Pathway" DropDownControlType="RadComboBox" /> 
                <telerik:GridDropDownColumn UniqueName="Enzyme" ItemStyle-Width="170px" ListTextField="EnzymeName" ListValueField="Enzyme" ListDataMember="KineticEnzymes" DataField="Enzyme" HeaderStyle-HorizontalAlign="Left" HeaderText="Enzyme" DropDownControlType="RadComboBox" /> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" ItemStyle-Width="5px" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Panel ID="Panel3" runat="server">  
                            <asp:CheckBox ID="ClintVmaxSwitch" runat="server" Checked='<%# Eval("ClintVmaxSwitch") %>' AutoPostBack="true" OnCheckedChanged="ClintVmaxSwitchChanged" /> 
                        </asp:Panel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn UniqueName="CLint" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="CLint" HeaderText="CLint" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="VMax" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="VMax" HeaderText="Vmax" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="KmKs" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="KmKs" HeaderText="Km(Ks)" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="fumic" ItemStyle-Width="50px" DataFormatString="{0:N3}" ItemStyle-HorizontalAlign="Center" DataField="fumic" HeaderText="fumic" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" ItemStyle-Width="5px" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Panel ID="Panel4" runat="server">  
                            <asp:CheckBox ID="SystemEnabled" runat="server" AutoPostBack="true" Checked='<%# Eval("SystemEnabled") %>' OnCheckedChanged="SystemEnabledChanged" /> 
                        </asp:Panel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridDropDownColumn UniqueName="System" ItemStyle-Width="170px" ListTextField="rCYPsystemName" ListValueField="System" ListDataMember="rCYPsystems" DataField="System"  HeaderText="rCYP system" HeaderStyle-HorizontalAlign="Left" DropDownControlType="RadComboBox" /> 
                <telerik:GridBoundColumn UniqueName="Value" DataField="Value" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" HeaderText="ISEF" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" ItemStyle-Width="5px" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Panel ID="Panel5" runat="server">  
                            <asp:CheckBox ID="bATypicalSwitch" runat="server" AutoPostBack="true" Checked='<%# Eval("bATypicalSwitch") %>' OnCheckedChanged="bATypicalSwitchChanged" /> 
                        </asp:Panel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn UniqueName="Alpha" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="Alpha" HeaderText="α" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="Beta" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="Beta" HeaderText="β" HeaderStyle-HorizontalAlign="Center" /> 
            </Columns> 
            <EditFormSettings CaptionFormatString="Edit details for route with Id {0}" CaptionDataField="Id">  
                <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> 
                <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> 
                <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
                <EditColumn ButtonType="ImageButton" /> 
            </EditFormSettings> 
        </MasterTableView> 
        <ClientSettings> 
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> 
        </ClientSettings> 
</telerik:RadGrid> 

protected void EnabledChanged(object sender, System.EventArgs e)  
    {  
        //first reference the panel which wraps the checkbox control through the Parent property  
        CheckBox chkBox = (sender as CheckBox);  
// Do something  

Each checkbox has it's own OncheckedChanged event handler which enables/disables various columns. There seems to be a problem around when the event handler gets triggered. If you put a breakpoint within the event handler the run the app. When in the grid edit mode, if you check any checkbox the event handler triggers, if you uncheck it again it does not trigger the event handler. It seems like only half the functionality has been implemented.  I have tried many different ways including using checkbox columns instead of using your panels method and adding the autopostback and event handler programatically, auto-generating columns but it still only seems to fire the OnCheckedChanged event in one direction. I have looked through your knowledgebase/forums without joy. Any help appreciated.

7 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 28 Nov 2008, 02:23 PM
Hi Steve,

Have you tried placing the CheckBox in the EditItemTemplate of the GridTemplateColumn? Check it out and let me know if it makes any difference.

Additionally, note that each grid column should have different UniqueName.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve
Top achievements
Rank 1
answered on 01 Dec 2008, 02:58 PM
Hi,
I have tried the suggestions you mentioned but it's still the same. The OnCheckedChanged="CheckedChanged" is only triggered in one direction either false to true or true to false depending on the inital state of the checkbox.

<telerik:RadGrid ID="RadGrid1" 
                     Skin="Vista"   
                     runat="server"   
                     Width="1050"   
                     GridLines="None" 
                     AllowAutomaticInserts="false" 
                     AutoGenerateColumns="False" 
                     AllowMultiRowSelection="False"   
                     AllowSorting="False"   
                     AllowPaging="False" 
                     OnItemCommand="RadGrid1_ItemCommand"   
                     OnItemCreated="RadGrid1_ItemCreated" 
                     OnUpdateCommand="RadGrid1_UpdateCommand"   
                     OnNeedDataSource="RadGrid1_NeedDataSource" 
                     OnItemDataBound="RadGrid1_ItemDataBound"   
                     ShowStatusBar="true"   
                     OnDeleteCommand="RadGrid1_DeleteCommand">  
            <PagerStyle Mode="NumericPages"></PagerStyle> 
            <MasterTableView DataKeyNames="Id" AllowMultiColumnSorting="True" EnableColumnsViewState="false" EditMode="InPlace" CommandItemStyle-Height="28px" CommandItemDisplay="Top">  
            <CommandItemTemplate> 
                      <table style="width:100%">  
                        <tr> 
                            <td> 
                                <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Edit.gif" />Edit selected route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Update.gif" />Update</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Cancel.gif" />Cancel editing</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnInitInsert" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/AddRecord.gif" />Add new route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnInsert" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Insert.gif" /> Add route</asp:LinkButton>&nbsp;&nbsp;  
                                <asp:LinkButton ID="btnDeleteSelected" runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Delete.gif" />Delete selected route</asp:LinkButton>&nbsp;&nbsp;  
                            </td> 
                            <td style="text-align:right;"><asp:LinkButton ID="btnRefresh" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="./Images/Refresh.gif" />Refresh</asp:LinkButton></td>  
                        </tr> 
                    </table>       
            </CommandItemTemplate> 
            <Columns> 
                 <telerik:GridTemplateColumn Visible="false" UniqueName="EnabledTemplateColumn" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Label ID="LabelEnabled" runat="server" Text='<%# Eval("Enabled") %>' />   
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Panel ID="Panel1" runat="server">  
                            <asp:CheckBox ID="Enabled" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" Checked='<%# Eval("Enabled") %>' /> 
                        </asp:Panel> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="MetaboliteTemplateColumn" ItemStyle-HorizontalAlign="Center" HeaderText="Metabolite" HeaderStyle-HorizontalAlign="Center">  
                    <ItemTemplate> 
                        <asp:Label ID="LabelMetabolite" runat="server" Text='<%# Eval("Metabolite") %>' />   
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Panel ID="Panel2" runat="server">  
                            <asp:CheckBox ID="Metabolite" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" Checked='<%# Eval("Metabolite") %>' /> 
                        </asp:Panel> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridDropDownColumn UniqueName="Pathway" ItemStyle-Width="250px" ListTextField="PathwayName" ListValueField="Pathway" ListDataMember="Pathways" DataField="Pathway" HeaderStyle-HorizontalAlign="Left" HeaderText="Pathway" DropDownControlType="RadComboBox" /> 
                <telerik:GridDropDownColumn UniqueName="Enzyme" ItemStyle-Width="250px" ListTextField="EnzymeName" ListValueField="Enzyme" ListDataMember="KineticEnzymes" DataField="Enzyme" HeaderStyle-HorizontalAlign="Left" HeaderText="Enzyme" DropDownControlType="RadComboBox" /> 
                <telerik:GridTemplateColumn UniqueName="CLintVmaxSwitchTemplateColumn" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Label ID="LabelClintVmaxSwitch" runat="server" Text='<%# Eval("ClintVmaxSwitch") %>' />   
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Panel ID="Panel3" runat="server">  
                            <asp:CheckBox ID="ClintVmaxSwitch" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" Checked='<%# Eval("ClintVmaxSwitch") %>' /> 
                        </asp:Panel> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn UniqueName="CLint" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="CLint" HeaderText="CLint" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="VMax" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="VMax" HeaderText="Vmax" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="KmKs" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="KmKs" HeaderText="Km(Ks)" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="fumic" ItemStyle-Width="50px" DataFormatString="{0:N3}" ItemStyle-HorizontalAlign="Center" DataField="fumic" HeaderText="fumic" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridTemplateColumn UniqueName="SystemEnabledTemplateColumn" DataField="SystemEnabled" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Label ID="LabelSystemEnabled" runat="server" Text='<%# Eval("SystemEnabled") %>' />   
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Panel ID="Panel4" runat="server">  
                            <asp:CheckBox ID="SystemEnabled" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" Checked='<%# Eval("SystemEnabled") %>' /> 
                        </asp:Panel> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridDropDownColumn UniqueName="System" ItemStyle-Width="250px" ListTextField="rCYPSystemName" ListValueField="System" ListDataMember="rCYPSystems" DataField="System"  HeaderText="rCYP system" HeaderStyle-HorizontalAlign="Left" DropDownControlType="RadComboBox" /> 
                <telerik:GridBoundColumn UniqueName="Value" DataField="Value" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" HeaderText="ISEF" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridTemplateColumn UniqueName="bATypicalSwitchTemplateColumn" ItemStyle-HorizontalAlign="Center" HeaderText="">  
                    <ItemTemplate> 
                        <asp:Label ID="LabelbATypicalSwitch" runat="server" Text='<%# Eval("bATypicalSwitch") %>' />   
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Panel ID="Panel5" runat="server">  
                            <asp:CheckBox ID="bATypicalSwitch" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" Checked='<%# Eval("bATypicalSwitch") %>' /> 
                        </asp:Panel> 
                    </EditItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn UniqueName="Alpha" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="Alpha" HeaderText="α" HeaderStyle-HorizontalAlign="Center" /> 
                <telerik:GridBoundColumn UniqueName="Beta" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center" DataField="Beta" HeaderText="β" HeaderStyle-HorizontalAlign="Center" /> 
            </Columns> 
            <EditFormSettings CaptionFormatString="Edit details for route with Id {0}" CaptionDataField="Id">  
                <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> 
                <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> 
                <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
                <EditColumn ButtonType="ImageButton" /> 
            </EditFormSettings> 
        </MasterTableView> 
        <ClientSettings> 
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> 
        </ClientSettings> 
</telerik:RadGrid> 
0
Iana Tsolova
Telerik team
answered on 02 Dec 2008, 01:19 PM
Hello Steve,

Can you try using the Bind() method for binding the checkboxes instead of the Eval() one and check if it makes any difference?

Additionally, I followed your scenario and prepared a working sample for you. Please check it out and let me know if it behaves as expected and if I missed something from your logic.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve
Top achievements
Rank 1
answered on 02 Dec 2008, 05:07 PM
Hi,
I tried your example code and it works.
I use this radgrid in a web user control. So I used the code in a web user control dropped onto a web form aspx page and it still works!
However when I drop this web user control into my web app, I have the same problem again ie it only fires the event when going from true to false or false to true depending on the inital state of the checkbox. 

In my app there is one web form aspx page which loads web user controls depending on which tab on a radtoolbar is clicked. The above web user control is one of these loaded controls. (Actually sitting in another web user control to make it more difficult!) Any idea what is interferring with the checkbox onCheckedChanged event?

     
0
Iana Tsolova
Telerik team
answered on 03 Dec 2008, 12:10 PM
Hi Steve,

Can you check if the user control works as expected if you add it declaratively on the page of your app instead of loading it dynamically?
Additionally, I suggest that you send me a code snippet with the way you load the control and where you load it. Note that if your page is ajaxified with RadAjax, you need to recreate the last loaded control on each Page.Load as described here.

Let me know how it goes.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve
Top achievements
Rank 1
answered on 04 Dec 2008, 04:48 PM

Hi,
I have tried the control as you suggested by adding it directly onto my app page and it works fine. When I load the control dynamically it stops working. The code I use to load the control is...
 

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" Skin="Outlook" MultiPageID="RadMultiPage1" OnTabClick="RadTabStrip1_TabClick" Width="100%" > 
        <Tabs> 
            <telerik:RadTab Text="<u>P</u>hysChem & Blood Binding" AccessKey="P" Value="0"></telerik:RadTab> 
            <telerik:RadTab Text="<u>A</u>bsorption" AccessKey="P" Value="1"></telerik:RadTab> 
            <telerik:RadTab Text="<u>D</u>istribution" AccessKey="D" Value="2"></telerik:RadTab> 
            <telerik:RadTab Text="<u>E</u>limination" AccessKey="E" Value="3"></telerik:RadTab> 
            <telerik:RadTab Text="<u>I</u>nteraction" AccessKey="I" Value="4"></telerik:RadTab> 
            <telerik:RadTab Text="<u>T</u>ransport" AccessKey="T" Value="5"></telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
      
    <br/><br/>  
      
    <asp:Panel id="Panel5" runat="server" /> 

code behind is...

protected void Page_Load(object sender, EventArgs e)  
    {  
        if (LatestLoadedControlName != null)  
        {  
            // User changes tabs for a particular compound  
            LoadUserControl(LatestLoadedControlName);  
        }  
        else  
        {  
            // User changes compound for a particular tab  
            SessionLatestLoadedControl();  
        }  
    }  
 
 
    public void SessionLatestLoadedControl()  
    {  
        int CompoundTab = 0;  
 
        // Get the current selected compound tab  
        CompoundTab = (int)System.Convert.ToSingle(Page.Session["CompoundTab"]);  
 
        switch (CompoundTab)  
        {  
            case 0:  
 
                // Loads the correct control, sets the tab strip and resets any Status Messages  
                LoadUserControl("compoundPhysChem.ascx");  
                RadTabStrip1.SelectedIndex = 0;  
                break;  
 
            case 1:  
 
                // Loads control etc  
                LoadUserControl("compoundAbsorption.ascx");  
                RadTabStrip1.SelectedIndex = 1;  
                break;  
 
            case 2:  
 
                // Loads control etc  
                LoadUserControl("compoundDistribution.ascx");  
                RadTabStrip1.SelectedIndex = 2;  
                break;  
 
            case 3:  
 
                // Loads control etc  
                LoadUserControl("Grid.ascx");  
                RadTabStrip1.SelectedIndex = 3;  
                break;  
 
            case 4:  
 
                // Loads control etc  
                LoadUserControl("compoundInteraction.ascx");  
                RadTabStrip1.SelectedIndex = 4;  
                break;  
 
            case 5:  
 
                // Loads control etc  
                LoadUserControl("compoundTransport.ascx");  
                RadTabStrip1.SelectedIndex = 5;  
                break;  
 
            default:  
 
                // Loads control etc  
                LoadUserControl("compoundPhysChem.ascx");  
                RadTabStrip1.SelectedIndex = 0;  
                break;  
        }  
    }  
 
 
 
    public void LoadUserControl(string controlName)  
    {  
        //Load the corresponding control  
        UserControl control = (UserControl)LoadControl(controlName);  
 
        //Clear panel controls and add the newly loaded control  
        Panel ctrlC = (Panel)this.FindControl("Panel5");  
        ctrlC.Controls.Clear();  
        ctrlC.Controls.Add(control);  
 
        //Save which control is loaded  
        LatestLoadedControlName = controlName;  
    }  
 
 
    // Get/sets latest loaded control  
    private string LatestLoadedControlName  
    {  
        get  
        {  
            return (string)Session["LatestLoadedControlName"];  
        }  
        set  
        {  
            Session["LatestLoadedControlName"] = value;  
        }  
    }  
 
 
    // Compound tab event handler  
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)  
    {  
        int tab = Convert.ToInt16(e.Tab.Value);  
         
            switch (tab)  
            {  
                case 0:  
 
                    // Loads the correct control, sets the tab strip  
                    Session["CompoundTab"] = "0";  
                    LoadUserControl("compoundPhysChem.ascx");  
                    break;  
 
                case 1:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "1";  
                    LoadUserControl("compoundAbsorption.ascx");  
                    break;  
 
                case 2:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "2";  
                    LoadUserControl("compoundDistribution.ascx");  
                    break;  
 
                case 3:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "3";  
                    LoadUserControl("Grid.ascx");  
                    break;  
 
                case 4:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "4";  
                    LoadUserControl("compoundInteraction.ascx");  
                    break;  
 
                case 5:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "5";  
                    LoadUserControl("compoundTransport.ascx");  
                    break;  
 
                default:  
 
                    // Loads control etc  
                    Session["CompoundTab"] = "0";  
                    LoadUserControl("compoundPhysChem.ascx");  
                    break;  
            }  
    } 

Grid.ascx is the control that I'm having problems with. ie the checkbox OnCheckedChanged event not firing when going true to false or false to true depending on the original state of the checkbox.

Thanks

   
0
Iana Tsolova
Telerik team
answered on 05 Dec 2008, 02:48 PM
Hi Steve,

Thank you for sending your code.

I looked it through and I can see your controls are loaded properly. Furthermore, I set up a test application using the preceding code and found that the grid in the Grid.ascx user control works as expected on my end. Could you please try the attached sample and let me know how it works on your side and what differs in your case?

Looking forward your reply,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Steve
Top achievements
Rank 1
Share this question
or