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

dropdownlist inside a radwindow

4 Answers 299 Views
Window
This is a migrated thread and some comments may be shown as answers.
sirisha
Top achievements
Rank 1
sirisha asked on 09 May 2011, 07:21 PM
I'm using a dropdownlist inside a radwindow.
If I set the Enable View state of Window manager to 'false', I'm unable to capture the selected item value of the dropdownlist on server side and if I set it to 'true' I'm able to capture the selected item value but the radwindow keeps on opening on each postback.

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 12 May 2011, 09:06 AM

Hi Sirisha,

I am not sure what your scenario is, but it looks like that the DropDownList inherits the disabled ViewState from the WindowManager. If that is the case simply try forcing it to on by adding EnableViewState="true" to its declaration. As explained in the following blog post: http://bloggingabout.net/blogs/dennis/archive/2004/09/29/1416.aspx - the dropdownlist requires its ViewState to populate the SelectedIndex value. As you can see in the video from my experiment now the dropdownlist seems to be working correctly.

On a side note -  if you have set the VisibleOnPageLoad property of the said RadWindow to true it is expected to show up on every postback. You should either reset it to false in a method, after whose execution you do not want the RadWindow visible, or simply remove it and open the RadWindow on the client side. The approach depends on your custom scenario and needs.

If the above does not help you resolve your issue please send me some more detail on your exact setup and code so that I can provide a more to the point answer.



Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
sirisha
Top achievements
Rank 1
answered on 12 May 2011, 03:08 PM
<telerik:RadWindowManager ID="WinMgr" runat="server" EnableViewState="false" DestroyOnClose="true" >
    <Windows>
               <telerik:RadWindow ID="WinCreate" runat="server" Modal="true" Height="210" Width="430" VisibleOnPageLoad="false"
         VisibleStatusbar="false" VisibleTitlebar="false" EnableShadow="true" OnClientClose="OnClientClose">
            <ContentTemplate>
                 <table style="width:100%;">
                    <tr>
                        <td align="left" style="border-width: 0px; width: 167px">
                            <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium" 
                                Text="Create Review Period"></asp:Label>
                        </td>
                        <td align="left" style="border-width: 0px; ">
                             </td>
                    </tr>
                    <tr>
                        <td align="right" style="border-width: 0px; width: 167px">
                            <asp:Label ID="Label5" runat="server" Font-Bold="True" Font-Size="Small" 
                                Text="Review Month"></asp:Label>
                        </td>
                        <td align="left" style="border-width: 0px;">
                            <telerik:RadComboBox ID="ddRevMonth" runat="server" AutoPostBack="true" EnableViewState="true">
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                      
                    <tr>
                    <td style="border-width: 0px;"></td>
                        <td align="center" style="border-width: 0px; ">
                            <asp:Button ID="btnSaveCreate" runat="server" Font-Bold="True" Font-Size="Small" 
                                onclick="btnRevPeriod_Click" Text="Save" />
                                             
                            <asp:Button ID="btnCancelCreate" runat="server" Font-Bold="True" Font-Size="Small" Text="Cancel"
                             OnClientClick="CloseCreateRevWindow()" />
                                
                        </td>
                    </tr>
                </table>
              
            </ContentTemplate>
        </telerik:RadWindow>
          </Windows>
    </telerik:RadWindowManager>
<asp:Button ID="btnCreate" runat="server" Font-Size="Small" 
                                                onclick="btnCreate_Click" Text="Create Review Period" />
protected void btnCreate_Click(object sender, EventArgs e)
    {
        //Get the Latest Review Period, if it exists
        DataLayer dl = new DataLayer();
        dl.ConnectionString = ConfigurationManager.AppSettings["SoxConnectionStr"].ToString();
  
        DataTable dt= dl.getLatestReviewPeriod();
  
        ddRevMonth.Items.Clear();
        int i = 0;
        int count = 0;
        DateTime month;
  
        if ((dt == null) || (dt.Rows.Count == 0))
        {
  
            month = DateTime.Today;
  
        }
        else
        {
            month=Convert.ToDateTime(dt.Rows[0]["ReviewDate"]);
        }
        while (i < 12)
        {
  
            DateTime NextMont = month.AddMonths(count);
            string year = NextMont.Year.ToString();
            RadComboBoxItem citem = new RadComboBoxItem();
            citem.Text = NextMont.ToString("MMMM").Substring(0, 3) + "-" + year.Substring(2, 2);
            citem.Value = NextMont.ToString();
            ddRevMonth.Items.Add(citem);
            foreach (GridDataItem item in RGReviewPeriod.Items)
            {
                string gMonth = item["ReviewMonth"].Text;
                if (citem.Text == gMonth)
                {
                    ddRevMonth.Items.Remove(citem);
                    i--;
                    break;
                }
            }
            i++;
            count++;
                          
        }
          
        WinCreate.VisibleOnPageLoad = true;
  
    }
protected void btnRevPeriod_Click(object sender, EventArgs e)
    {
                 
        DateTime revMonth = Convert.ToDateTime(ddRevMonth.SelectedItem.Value);
        DateTime revDate = Convert.ToDateTime(revMonth.Month + "/1/" + revMonth.Year);
        try
        {
            DataLayer dl = new DataLayer();
            dl.ConnectionString = ConfigurationManager.AppSettings["SoxConnectionStr"].ToString();
            int result = dl.insertReviewPeriod(revDate, user);
          }
        catch (Exception ex)
        {
            Utilities.ErrorLogger errLog = new Utilities.ErrorLogger();
            errLog.WriteToErrorLog(ex.Message, ex.StackTrace, "btnRevPeriod_Click in Set Review Period",     
           HttpContext.Current.Session["Name"].ToString());
            Response.Redirect("~/Aspx/Messages/errMessage.aspx?err=error");
        }
         
  
    }

Above is the code I'm using in  my project.I'm not sure what I'm doing wrong..
0
Accepted
Kalina
Telerik team
answered on 20 May 2011, 11:40 AM

Hello Sirisha,

Let me suggest you remove the AutoPostBack property of the RadComboBox and get the SelectedValue in this way:
protected void btnRevPeriod_Click(object sender, EventArgs e)
{
    RadComboBox InnerCombo = WinCreate.ContentContainer.FindControl("ddRevMonth") as RadComboBox;
    DateTime revMonth = Convert.ToDateTime(InnerCombo.SelectedValue);
...
...
...

You can find more details at the sample attached.
Please let me know if this helps.

Greetings,
Kalina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
sirisha
Top achievements
Rank 1
answered on 23 May 2011, 03:04 PM
Thank you.. it worked.
Tags
Window
Asked by
sirisha
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
sirisha
Top achievements
Rank 1
Kalina
Telerik team
Share this question
or