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

Blank Combobox after postback

3 Answers 91 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 2
Kris asked on 12 Jun 2011, 01:57 PM
Hello,

I want to achieve that when a user makes a selection with the combobox (cboVolgnr) 016 in my example (see pic), the results comes up and the user wants to clean up his selection but the selection is still there. I thought that the code was complete but it still doesn't works... My code:

 

<td style="width:50px">Volgnr</td>

<td style="width:75px"><telerik:RadComboBox ID="cboVolgnr" Runat="server" Width="75px" Filter="StartsWith"><HeaderTemplate>
<ul><li class="colvolg1">Volgnr</li><li class="colvolg2">Code</li><li class="colvolg3">EI</li><li class="colvolg4">Omschr</li></ul></HeaderTemplate>

 

<ItemTemplate>

 

<ul>

 

<li class="colvolg1"><%#Eval("Volgnr")%></li >

 

<li class="colvolg2"><%#Eval("Code")%></li >

 

<li class="colvolg3"><%#Eval("EI")%></li>

 

<li class="colvolg4"><%#Eval("Omschr")%></li >

 

</ul >

 

</ItemTemplate>

 

</telerik:RadComboBox>

 

</td >

cboVolgnr.Text = ""

 

 

 

 

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me

 

.Load

 

 

 

 

 

    Dim cn As New SqlConnection(cnnBN.ToString), cmd As SqlCommand, dr As

 

SqlDataReader

 

 

 

 

 

    Dim strSQL As String = "SELECT * FROM tblBWPeriodes WHERE DJ = "

 

& strDJ

 

 

 

 

 

    Try

 

 

 

 

        cn.Open()

 

 

 

 

        cmd = New SqlCommand(strSQL, cn)

 

 

 

 

        dr = cmd.ExecuteReader

 

 

        combo.DataTextField = 

 

"volgnr"

 

 

 

 

        combo.DataValueField = "volgnr"

 

 

 

 

        combo.DataSource = dr

 

 

 

 

        combo.DataBind()

 

 

        combo.Skin = 

 

"Office2007"

 

 

 

 

    Catch ex As Exception

 

 

 

 

        Throw ex

 

 

 

 

    End

 

Try

 

 

 

    dr = Nothing

 

 

 

 

    cmd = Nothing

 

 

 

 

    cn.Dispose()

 

 

 

 

    cn = Nothing

 

 

 

 

    cboVolgnr.HighlightTemplatedItems = True

 

 

 

 

    cboVolgnr.AllowCustomText = True

 

 

 

 

    cboVolgnr.EmptyMessage = "Alles"

 

 

 

 

    cboVolgnr.DropDownWidth = 500

 

 

     cboVolgnr.Height = 375

 

 

 

End

 

Sub

 

Protected Sub btnCriteria_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles

 

btnCriteria.Click

 

 

 

...

 

 

 

 

    cboVolgnr.Text = ""

 

 

 

 

End

 

Sub

Is there something I am missing?  Can you give me a help?

Kind regards,
Kris

 

 

 

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Kris
Top achievements
Rank 2
answered on 14 Jun 2011, 08:15 PM
No one has the answer?
0
Accepted
Kalina
Telerik team
answered on 16 Jun 2011, 12:07 PM
Hello Kris,

In general when RadComboBox control is "read-only" - there is always a selected item in it.
You can overcome the issue by setting the AllowCustomText property of the RadComboBox to "true".
I created a small example for you - please find it attached.

All the best,
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
Kris
Top achievements
Rank 2
answered on 16 Jun 2011, 07:35 PM
Hello Kalina,

Thank you for the answer.  I did the set=true of AllowCustomText but I saw in your code that you also used the clearselection() which I did not.  That did it!  Now it works.  That you very much;

Kind regards,
Kris
Tags
ComboBox
Asked by
Kris
Top achievements
Rank 2
Answers by
Kris
Top achievements
Rank 2
Kalina
Telerik team
Share this question
or