[CLOSED] Combobox Data Binding Problem

  1. #1

    [CLOSED] Combobox Data Binding Problem

    Hi all,

    I have Faced a Problem with Combobox Databinding means if we r Having 4 combobox items as A,B,C,D and for this Items Value wil be 1,2,3,4 ..here Combobox Id is cmb1.

    then if we set cmb1.selectedItem.Value and if we select A then the value will be 1.. here i set the Combo property as ForceSelection="True" ..

    then i select A and i enter some thing in combo like asasa then suddnly i click on submit button with out using cursor then cmb1.selectedItem.Value will be A. not 1.

    so how to rectify this Problem plz solve this..

    See this Example


    <ext:ComboBox ID="cmb1" runat="server" ForceSelection="true" >
                            <Items>
                                <ext:ListItem Text="A" Value="1" />
                                <ext:ListItem Text="B" Value="2" />
                                <ext:ListItem Text="C" Value="3" />
                                <ext:ListItem Text="D" Value="4" />
                            </Items>
                            </ext:ComboBox>
    In code behind:

    int No=0;
    
    No=cmb1.SelectedItem.value;
    Here the No value we will get as 1.this will be correct.

    But the Problem is when we Select A and Type as AXYZ and Click on Button then

    No=cmb1.SelectedItem.value; // here the No is getting like AXYZ  ..
    so how to Rectify this Problem...plz Help..






    Thanks in Advance..
    Last edited by Daniil; Feb 09, 2011 at 1:55 PM. Reason: Please use [CODE] tags for code only, [CLOSED]
  2. #2
    Hi,

    What way we can reproduce the issue?

    I was not able to reproduce it using this code under Ext.Net 1.0.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void GetValue(object sender, DirectEventArgs e)
        {
            int No = 0;
            No = Int32.Parse(ComboBox1.SelectedItem.Value);
            X.Msg.Alert("DirectEvent", No).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox ID="ComboBox1" runat="server" ForceSelection="true">
            <Items>
                <ext:ListItem Text="A" Value="1" />
                <ext:ListItem Text="B" Value="2" />
                <ext:ListItem Text="C" Value="3" />
                <ext:ListItem Text="D" Value="4" />
            </Items>
            <SelectedItem Value="1" />
        </ext:ComboBox>
        <ext:Button runat="server" Text="Test" OnDirectClick="GetValue" />
        </form>
    </body>
    </html>
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    What way we can reproduce the issue?

    I was not able to reproduce it using this code under Ext.Net 1.0.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void GetValue(object sender, DirectEventArgs e)
        {
            int No = 0;
            No = Int32.Parse(ComboBox1.SelectedItem.Value);
            X.Msg.Alert("DirectEvent", No).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox ID="ComboBox1" runat="server" ForceSelection="true">
            <Items>
                <ext:ListItem Text="A" Value="1" />
                <ext:ListItem Text="B" Value="2" />
                <ext:ListItem Text="C" Value="3" />
                <ext:ListItem Text="D" Value="4" />
            </Items>
            <SelectedItem Value="1" />
        </ext:ComboBox>
        <ext:Button runat="server" Text="Test" OnDirectClick="GetValue" />
        </form>
    </body>
    </html>

    Hi Daniil,,
    im using Coolite 0.8 in 0.8 when i try to give like No = Int32.Parse(ComboBox1.SelectedItem.Value);
    then it will take as No='A' Only..so How i solve this in 0.8 ..
  4. #4
    Hi,

    Confirmed. There is an issue.

    It would be best to avoid using ForceSelection and handle this situation manually on client (to avoid AjaxEvent) or on server side to avoid exception.

    For example, on client side it can look something like this:

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void GetValue(object sender, AjaxEventArgs e)
        {
            int No = 0;
            No = Int32.Parse(ComboBox1.SelectedItem.Value);
            Ext.Msg.Alert("GetValue", No.ToString()).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Coolite 0.8.x Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:ComboBox ID="ComboBox1" runat="server">
            <Items>
                <ext:ListItem Text="A" Value="1" />
                <ext:ListItem Text="B" Value="2" />
                <ext:ListItem Text="C" Value="3" />
                <ext:ListItem Text="D" Value="4" />
            </Items>
            <SelectedItem Value="1" />
        </ext:ComboBox>
        <ext:Button runat="server" Text="GetValue">
            <Listeners>
                <Click Handler="var v = parseInt(ComboBox1.getValue()); if (isNaN(v)) { alert('Incorrect value'); return false; }" />
            </Listeners>
            <AjaxEvents>
                <Click OnEvent="GetValue" />
            </AjaxEvents>
        </ext:Button>
        </form>
    </body>
    </html>
    The second option can be setting ReadOnly="true".

    Example
    <ext:ComboBox ID="ComboBox1" runat="server" ReadOnly="true">
  5. #5
    This thread is related (generally speaking, duplicate) to:
    http://forums.ext.net/showthread.php?12330

Similar Threads

  1. ComboBox data binding
    By AlexMaslakov in forum 1.x Help
    Replies: 3
    Last Post: Jun 13, 2013, 9:04 AM
  2. Data not binding into ComboBox
    By nagesh in forum 1.x Help
    Replies: 5
    Last Post: Jul 12, 2012, 2:35 PM
  3. [CLOSED] ComboBox in user control binding but not showing data
    By Digital.Dynamics in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: May 08, 2012, 12:09 PM
  4. Replies: 4
    Last Post: May 31, 2011, 3:53 PM
  5. Combobox not binding data
    By Satyanarayana murthy in forum Open Discussions
    Replies: 0
    Last Post: Jun 27, 2009, 12:22 PM

Posting Permissions