PDA

View Full Version : [OPEN] ComboBox Value



Timothy
Sep 11, 2008, 5:54 PM
Hello,

The example below will demonstrate that I can not submit a value in a ComboBox that is not in the list:



<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btnDemo_Click(object sender, AjaxEventArgs e)
{
lblTest.Text = "Omg ... you selected: " + drpEmployeeRole.SelectedItem.Value;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<p><a href="Example.aspx">Reload</a></p>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
<ext:ScriptManager ID="ScriptManager2" runat="server" Theme="Gray" />
<ext:ComboBox ID="drpEmployeeRole"
runat="server"
Editable="True"
EmptyText="Provide a Member Role ..."
Width="185">
<Items>
<ExtJS:ListItem Text="Consultant" />
<ExtJS:ListItem Text="Coordinator" />
<ExtJS:ListItem Text="Project Coordinator" />
<ExtJS:ListItem Text="Project Manager" />
</Items>
</ext:ComboBox>
<ext:Button ID="btnDemo" runat="server" AutoPostBack="False" Text="Save">
<AjaxEvents>
<Click OnEvent="btnDemo_Click" />
</AjaxEvents>
</ext:Button>
<ext:Label ID="lblTest" runat="server" Text="Waiting ..." />
</form>
</body>
</html>


Replication steps:

1. Enter "Timothy" into Combobox
2. Click "Save"
3. Notice it doesn't show Timothy as selected
4. Select "Consultant" from Combobox (or type it)
5. Click "Save"
6. Notice it knows my selection

I thought it might be the SelectedItem property, because I haven't really selected anything, but even the underlying Value property is null. Have I missed a property setting to make this work?

Cheers,
Timothy

leonardobag
Jul 03, 2009, 10:03 PM
any update on this? i've got the same problem.
Thanks.

Vladimir
Jul 04, 2009, 6:42 AM
Hi,

The solution is set ForceSelection="false" for ComboBox