RadWindow not maintaining postback values correctly

2 posts, 0 answers
  1. James
    James avatar
    7 posts
    Member since:
    Jun 2009

    Posted 17 May 2010 Link to this post

    Hi, I am collecting information from the user in a RadWindow.

    The RadWindow contains a repeater control.  Each item in the Repeater control contains a regular asp.net CheckBox and TextBox control.  When I iterate through the items of the repeater on postback, the items do not contain the values that were entered by the user, but default values instead.

    The markup looks like this:

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">





                    Title="Manage Categories" 












                    <asp:Label ID="lblRulesetCategories" runat="server"></asp:Label><br /><br />

                    <asp:Label ID="lblErrorRulesetCategories" ForeColor="Red" runat="server"></asp:Label>

                    <asp:Repeater ID="rptrRulesetCategories" runat="server">


                            <asp:CheckBox id="cbRulesetCategorySelected" Checked='<%# Eval("IsSelected") %>' runat="server"></asp:CheckBox>

                            <asp:HiddenField ID="hdnCategoryId" Value='<%# Eval("CategoryId") %>' runat="server" />

                            <asp:Label ID="lblRulesetCategoryName" Text='<%# Eval("Name") %>' runat="server"></asp:Label>

                            <asp:TextBox ID="tbRulesetCategorySequence" Text='<%# Eval("Sequence") %>' runat="server"></asp:TextBox>

                            <asp:CompareValidator ID="cvRulesetCategorySequence" ControlToValidate="tbRulesetCategorySequence" Operator="DataTypeCheck" Type="Integer" Text="* Invalid" Display="Dynamic" runat="server"></asp:CompareValidator>

                            <br />



                    <br />

                    <br />

                    <asp:Button ID="btnManageCategoriesSave" Text="Save" OnClick="btnManageCategoriesSave_Click" runat="server" />

                    <asp:Button ID="btnManageCategoriesCancel" Text="Cancel" OnClick="btnManageCategoriesCancel_Click" runat="server" />





    The code-behind looks like this:

        protected void btnManageCategoriesSave_Click(object sender, EventArgs e)


            // Get collection of checked ruleset categories in repeater

            var checkedCategoryIDs = from ri in this.rptrRulesetCategories.Items.Cast<RepeaterItem>()

                                     let hdnCategoryId = (HiddenField)ri.FindControl("hdnCategoryId")

                                     let cbRulesetCategorySelected = (CheckBox) ri.FindControl("cbRulesetCategorySelected")

                                     let tbRulesetCategorySequence = (TextBox)ri.FindControl("tbRulesetCategorySequence")

                                     select new


                                         CategoryId = Convert.ToInt32(hdnCategoryId.Value),

                                         Checked = cbRulesetCategorySelected.Checked,

                                         Sequence = tbRulesetCategorySequence.Text == "" ? null : tbRulesetCategorySequence.Text



    When I hover over the checkedCategoryIDs variable, the Checked value is always false and the Sequence value is always blank for all items even though I do check various checkboxes, and enter values into various sequence textboxes.  This doesn't appear to be a problem with my LINQ statement, as I can also enter the following into the immediate window and still get a blank value:

    ? ((TextBox) this.rptrRulesetCategories.Items[0].FindControl("tbRulesetCategorySequence")).Text

    The radwindow was working before when I was using a checkboxlist instead of a repeater, and I was using the same approach with collecting the values in a LINQ statement...

    Any ideas on how I can resolve this?


    ** UPDATE **
    My bad, the radwindow works fine.  I was rebinding the repeater, and erasing the values before I had a chance to retrieve them...
  2. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 20 May 2010 Link to this post

    Hi James,

    I built up a tets demo based on your code and I was able to reproduce the problem. However, it turned out to be a general ASP problem because it can be reproduced without using RadWindow or any RadControls at all. I searched teh net and found the following solution:


    I modified my demo accordingly and it started working. You can examine and test my sample code below:


    <form id="form1" runat="server">
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
      <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
              <telerik:RadWindow ID="rwManageCategories" runat="server" Title="Manage Categories"
                  Height="400px" Width="600px" Left="150px" ReloadOnShow="true" VisibleOnPageLoad="true"
                  ShowContentDuringLoad="false" Modal="true" Behaviors="None" KeepInScreenBounds="True"
                      <asp:Label ID="lblRulesetCategories" runat="server"></asp:Label><br />
                      <br />
                      <asp:Label ID="lblErrorRulesetCategories" ForeColor="Red" runat="server"></asp:Label>
                      <asp:Repeater ID="rptrRulesetCategories" runat="server" EnableViewState="false">
                              <asp:TextBox ID="tbRulesetCategorySequence" Text='<%# Eval("FirstColumn") %>' runat="server"></asp:TextBox>
                              <br />
                      <br />
                      <br />
                      <asp:Button ID="btnManageCategoriesSave" Text="Save" OnClick="btnManageCategoriesSave_Click"
                          runat="server" />
                      <asp:Button ID="btnManageCategoriesCancel" Text="Cancel" runat="server" />

    code - behind:

    protected void Page_Load(object sender, EventArgs e)
        rptrRulesetCategories.DataSource = GetData();
    protected void btnManageCategoriesSave_Click(object sender, EventArgs e)
    protected DataTable GetData()
        DataTable tbl = new DataTable();
        tbl.Columns.Add(new DataColumn("FirstColumn"));
        tbl.Columns.Add(new DataColumn("SecondColumn"));
        tbl.Columns.Add(new DataColumn("ThirdColumn"));
        tbl.Columns.Add(new DataColumn("FourthColumn"));
        tbl.Rows.Add(new object[] { "firstRecord1", "firstRecord2", "firstRecord3", "firstRecord4" });
        tbl.Rows.Add(new object[] { "secondRecord1", "secondRecord2", "secondRecord3", "secondRecord4" });
        tbl.Rows.Add(new object[] { "thirdRecord1", "thirdRecord2", "thirdRecord3", "thirdRecord4" });
        return tbl;

    I hope that my reply and research are helpful.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top