[SOLVED] [1.0] MVC and AutoDataBind
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
12»»
[SOLVED] [1.0] MVC and AutoDataBind
Subscribe
Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 6:26:02 AM

Group: Coolite Premium Member & Early Adopter
Hello,

The following example demonstrates an issue with the AutoDataBind property on the ComboBox

ExampleController.cs:

namespace Web
{
    public class MyClass
    {
        public string Name { get; set; }
        public string Select { get; set; }
    }
}

namespace Web.Controllers
{
    public class ExampleController : Controller
    {
        public ActionResult Index()
        {
            return View(new MyClass
            {
                Name = "Timothy",
                Select = "One"
            } );
        }
    }
}


Index.aspx:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Web.MyClass>" %>

<!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>Example</title>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:TextField ID="TextField1" runat="server" AutoDataBind="true" Text="<%# Model.Name %>" />
    <ext:ComboBox ID="ComboBox1" runat="server">
        <Items>
            <ext:ListItem Text="One" Value="One" />
            <ext:ListItem Text="Two" Value="Two" />
            <ext:ListItem Text="Three" Value="Three" />
            <ext:ListItem Text="Four" Value="Four" />
            <ext:ListItem Text="Five" Value="Five" />
        </Items>
        <SelectedItem AutoDataBind="true" Text="<%# Model.Select %>" />
    </ext:ComboBox>
</body>
</html>


Replication steps:
1. Load page
2. Notice Timothy has been populated but One in the ComboBox has not

Cheers,
Timothy


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/4/2010 6:40:37 AM

Group: Core Development Team
Hi,

Selection is possible by value only (Text property is used for reading, after submit to read the text of the selected item)

Therefore please use Value property only

<SelectedItem AutoDataBind="true" Value="<%# Model.Select %>" />


--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 6:50:36 AM

Group: Coolite Premium Member & Early Adopter
Thanks for the information on the Text field. I've tried the Value field and I have the same result, not working. Can you confirm on your end?

Cheers,
Timothy


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 7:47:57 AM

Group: Coolite Premium Member & Early Adopter
Any suggestsions vladsch?


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/4/2010 8:10:36 AM

Group: Core Development Team
Hi,

Investigating... Under MVC the AutoDataBind doesn't work for SelectedItem 

--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 3/4/2010 9:38:39 AM

Group: Core Development Team
Hi,

Fixed. Please update Ext.Net 

--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 9:59:24 AM

Group: Coolite Premium Member & Early Adopter
Thanks vladsch!

Question for you, when I submit a form with a ComboBox named ComoBox1 the values that are sent are the following:

ComboBox1 = Text value
ComboBox1_SelIndex = Index value
ComboBox1_Value = Value

Would it be possible to switch make the value for ComboBox1 be the actual value? And remove ComboBox1_Value and add ComboBox1_Text?

Would be helpful.

Cheers


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 5/31/2010 7:54:27 AM
Posts: 61,
Posted 3/4/2010 11:07:46 AM

Group: Coolite Premium Member & Early Adopter
Yeah, I would really like to see that happen too. I guess it would break existing code though. Maybe an optional attribute could enable such behavior?

---
Sandor Drieënhuizen
Subspace
Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 11:28:59 AM

Group: Coolite Premium Member & Early Adopter
Would be nice if we could have an option to ommit the additional values from being submitted in the post.

For example, when I have 10 combobox fields on a page it's sending 30 values back to the server -- when 20 of them are useless

Cheers,
Timothy


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

Last Login: 6/17/2010 4:30:38 PM
Posts: 1,239,
Posted 3/4/2010 1:45:33 PM

Group: Coolite Premium Member & Early Adopter
Argh, would be extremely useful because now my TryUpdateModel fails miserably

Let me know what you think vladsch.

Cheers,
Timothy


----
Timothy Grant Vogelsang
tvogelsang [at] esolutionsgroup [dot] ca
Project Manager / Senior Software Developer
Microsoft .NET Framework 3.5
Coolite Toolkit 1.0

« Prev Topic | Next Topic »
12»»
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 8:41pm