-
"NULL" value in ComboBox
Hello,
I have a problem with setting value "NULL" (as text) to ComboBox. I think it is a bug.
A workaround is to add "null" (lowercase) to the combobox list (and then set Value = "null").
Ext.Net version 3.3
Regards
P.K.
test.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="pages_test" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
test.aspx.cs
Code:
using System;
using System.Collections.Generic;
using System.Web;
using Ext.Net;
public partial class pages_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ResourceManager res_man = new ResourceManager();
res_man.IDMode = IDMode.Explicit;
res_man.DisableViewState = true;
res_man.AjaxViewStateMode = Ext.Net.ViewStateMode.Disabled;
res_man.DirectMethodNamespace = "dm";
this.Controls.Add(res_man);
Panel panel1 = new Panel() {ID = "panel1", Width = 300, Height = 200 };
form1.Controls.Add(panel1);
ComboBox combo1 = new ComboBox() { ID = "combo1" };
combo1.Items.Add(new ListItem("NOT NULL"));
combo1.Items.Add(new ListItem("NULL"));
panel1.Items.Add(combo1);
combo1.Value = "NULL";
}
}
-
Hello P.K.!
Please use this:
Code:
combo1.SelectedItems.Add(new Ext.Net.ListItem("NULL"));
Although it may look much longer, it is a more appropriate way on setting the selected item in combo boxes. The .Value
approach should work, but in fact, the string NULL
is interpreted as "assume the default value" and is not sent to client side to build the page at all. Adding the item to the selection ensures an actual pair name-value should be matched (although only the value part is important.
Hope this helps!
-
Thank you, it works.
Regards
P.K.