Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > Selected Value Resets-radcombobox

Not answered Selected Value Resets-radcombobox

Feed from this thread
  • Reeba avatar

    Posted on Feb 8, 2012 (permalink)

    I have a repeater control in which I hava 2 labels and a radcombo box. I am able to populate the labels and the radcombobox.

    The way it should work is I need to map a label text to the value in the radcombo box . The problem is even though the value in the combo is selected it keeps reseting to the first item in the drop down list.
    Can someone help me to keep the selected value of the radcombo box selected.See attached jpg.

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
        </telerik:RadStyleSheetManager>
        <h2>Server Request Dynamic Reports Creation</h2>
    <p>
          
        <telerik:RadScriptManager ID="rsmDynamicReports" Runat="server">
        </telerik:RadScriptManager>    </p>
      
           
          <telerik:RadAjaxPanel ID="RadDynamicRpt" runat="server" HorizontalAlign="NotSet"  >
             <table id="telerikTable"  >
                <tr valign = "top">
                    <td  > <asp:Label ID="lblRptServer" runat="server" Text="Report Server :" Font-Size="Small"></asp:Label></td>
                                <td colspan= "2" > <asp:DropDownList ID="ddlDynamicRpt" runat="server" AutoPostBack="True" ForeColor="#3366FF" Font-Size="Small">
                                        <asp:ListItem Value="0">--Select One--</asp:ListItem> </asp:DropDownList></td>
             
                </tr
                <tr valign="top">
                    <td colspan="3" ><asp:Label ID="lblReportName" runat="server" Text="Select Report :" Font-Size="Small"></asp:Label></td>
              
                </tr>
                <tr valign="top">
                    <td  ></td>
                        <td  colspan="2"
                <div style="width: 396px">
                    <asp:Panel ID="panel1" Width="400px" BorderStyle="Solid" BorderWidth ="1pt" ScrollBars="Vertical"    runat="server">         
                    <asp:TreeView ID="tvCatalog" runat="server" AutoGenerateDataBindings="true" 
                            BorderStyle= "none" Height="100px" Font-Size="Small" >
                 
                    </asp:TreeView>      
                
                    </asp:Panel>                     
                
            </div></td>
             
         </tr>
          <tr valign="top">
            <td  ><asp:Label ID="label1" runat="server" Text="Report Path :" Font-Size="Small"></asp:Label></td>
            <td colspan="2"><telerik:RadTextBox ID="RadPath" runat="server" Width=398px 
                    ForeColor="#3366FF" BorderStyle="Solid" BorderWidth="1pt" Enabled="False" 
                    Font-Size="Small"></telerik:RadTextBox></td>
              
         </tr>
         <tr valign="top">
         <td></td>
         <td colspan="2">
                     <table>
                      
                <asp:Repeater ID="rptFields" runat="server" >
                    <HeaderTemplate>
                        <tr>
                            <td width="150px">
                                <asp:Label ID="lblReportParam" runat="server"  ForeColor="Blue" Text="Report Parameter" Font-Bold="true"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="lblServeRequest" runat="server" ForeColor="Blue"  Text="Server Request Field" Font-Bold="true"></asp:Label>
                            </td>
                        </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td>
                                <asp:Label ID="lblReportParamField" runat="server" Text='<%# Bind("RptParam") %>'></asp:Label>
                            </td>
                            <td>
                                  
                     <telerik:RadComboBox ID="rcbServerRequest" runat="server"  OnItemDataBound="rptFields_ItemDataBound" >
                       
                     </telerik:RadComboBox>
                       
      
                            </td>
                              
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                </table>
      
      
           
         </td>
         </tr
         <tr valign = "top">
                    <td  > </td>
                                <td colspan= "2"
                                    <asp:Button ID="btnrpt" runat="server" Text="Submit" /></td>
             
                </tr
         </table>
            </telerik:RadAjaxPanel>
      
    </asp:Content>

     

    Attached files

    Reply

  • Posted on Feb 9, 2012 (permalink)

    Hello,

    I tried to reproduce the same in this version 2011.2.915.35 but no avail. Try the following code.
    aspx:
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource">
     <HeaderTemplate>
      <asp:Label ID="Label1" runat="server"></asp:Label>
      <asp:Label ID="Label2" runat="server"></asp:Label>
     </HeaderTemplate>
     <ItemTemplate>
      <asp:PlaceHolder ID="pl" runat="server"></asp:PlaceHolder>
      <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="EmployeeID" DataValueField="EmployeeID">
      </telerik:RadComboBox>
     </ItemTemplate>
    </asp:Repeater>

    Thanks,
    Princy.

    Reply

  • Reeba avatar

    Posted on Feb 9, 2012 (permalink)

    I am populating the rad combo box  using code behind. The problem arises when I select a value in the combo box it does not keep the value selected, it reverts back to the first value in the radcombo box. I tried a itemdatabound on the repeater but it is giving me errors: Here is the code behind that I use to bind the radcombo box the first time:

    Dim t As New System.Data.DataTable
               t.Columns.Add("RptParam")
               Dim newRow(1) As Object
               'Loop to get parameter names
               For Each rp In parameters
                   If rp.Prompt <> "" Then
                       t.Rows.Add(New Object() {rp.Name})
                   End If
               Next rp
               rptFields.DataSource = t
               rptFields.DataBind()
               Dim oParams As New NameValueCollection
               Dim oDTT As DataTable = GetData(My.Settings.EmailLogging, "usp_GETMapParameter_Details", CommandType.StoredProcedure, oParams)
               For i As Integer = 0 To rptFields.Items.Count - 1
                   Dim rcbServerRequest As RadComboBox = DirectCast(rptFields.Items(i).FindControl("rcbServerRequest"), RadComboBox)
                   rcbServerRequest.DataTextField = "Parameter"
                   rcbServerRequest.DataValueField = "EmailType"
                   rcbServerRequest.DataSource = oDTT
                   rcbServerRequest.DataBind()
               Next

    Reply

  • Dimitar Terziev Dimitar Terziev admin's avatar

    Posted on Feb 13, 2012 (permalink)

    Hi,

    The experienced behavior usually occurs when you have multiple items with one and the same value. Please ensure that you have unique value for your items, and if the "EmailType" field in your database has duplicating values, you better store this information as custom attribute rather then a value of your items.

    More information about the custom attributes could be found here.

    All the best,
    Dimitar Terziev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > Selected Value Resets-radcombobox
Related resources for "Selected Value Resets-radcombobox"

ASP.NET ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]