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

ata Keeps Getting Bound in RadComboBox

2 Answers 69 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tavoris
Top achievements
Rank 1
Tavoris asked on 03 Oct 2008, 03:17 PM
Hi Guys,

I have a RadComboBox who'se items are bound from a SQL table using "AppendDataBoundItems."  When my page initially loads, the data is bound only once (as expected).  Every time, however, I either run a query on the page, or hit the "Clear" button (which clears all of the fields from their selected values), this data gets appended again, & again, & again...

Scenario:
1.  The page loads, and the values are appended once.
2.  I run a query, and the values are appended again, showing up 2 times in the dropdown.
3.  I hit the clear button, and the values are appended again, showing up 3 times in the dropdown.

All I need is for this data to be appended once (when the page initally loads), and no other times.  Here's my corresponding code...

ASPX Page:

 <radC:RadComboBox ID="CodeDescPermType" runat="server" DataSourceID="SqlDataSource1" AppendDataBoundItems="True"
            SkinsPath="~/RadControls/ComboBox/Skins" Width="150px" DataTextField="CodeDesc" DataValueField="CodeDesc" ExpandEffect="Barn" MarkFirstMatch="True">
            <Items>
                <radC:RadComboBoxItem ID="RadComboBoxItem2" runat="server" Text="- Select Permit Type -" Value="- Select Permit Type -" />
            </Items>
        </radC:RadComboBox>

<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="CodeDescPermType"
            ErrorMessage="* Must Select Permit Type" Operator="NotEqual" ValueToCompare="- Select Permit Type -"></asp:CompareValidator>


        <asp:SqlDataSource ID="SQLDataSource1" runat="server" ConnectionString = "<%$ ConnectionStrings:BuildingInspPermits %>"
            SelectCommand="SELECT [CodeDesc] FROM [BLDG_PERMIT_TYPE_CODES] "></asp:SqlDataSource>



ASPX.VB Page (That Clears the Value When the "Clear" Button's Selected):

    Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
        lblMsg.Text = ""
     CodeDescPermType.ClearSelection()
 ' RadComboBoxItem2.ClearItems()
  StartDate.Text = StartDate.MinDate
  EndDate.Text = EndDate.MaxDate
        gvRoutes.Visible = False

End Sub


I know this is terribily simple, but I just can't seem to figure it out.  Any help would be greatly appreciated...  Thanx!


- Tav






2 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 06 Oct 2008, 01:13 PM
Hello Tavoris,

Do you call the DataBind method of RadComboBox anywhere in your project? I suggest if you do that to do it only if Page.IsPostBack property returns false.

Also you can see the attached project illustrating that everything works as expected at our side. Hope it helps.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tavoris
Top achievements
Rank 1
answered on 06 Oct 2008, 05:15 PM
EUREKA!!!  That did it!  It was starring me in the face the entire time.  I guess I had just looked at it too long to see it...  Thanx-again!  :@ D
Tags
ComboBox
Asked by
Tavoris
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Tavoris
Top achievements
Rank 1
Share this question
or