[CLOSED] ControlParameter PropertyName for selected value of Combobox

  1. #1

    [CLOSED] ControlParameter PropertyName for selected value of Combobox

    I have two questions on how to use an object data source together with a combo box:

    1. I am trying to use the selected value of a combobox as the control parameter for the select method of a object data source. Which property of the EXT combobox do I use? ('SelectedItem' generates the error "Type 'Ext.Net.ListItem' in Assembly 'Ext.Net, Version=2.1.0.21329, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87' is not marked as serializable. " , 'SelectedValue' as with a standard ASP drop down list does not work.

    <asp:ObjectDataSource ID="odsStatus" runat="server" SelectMethod="GetStatus" TypeName="Test.Models.Application" >
        <SelectParameters>
            <asp:ControlParameter ControlID="cbApplicationStatus" Name="ParentNode" PropertyName="SelectedValue" Type="Int32" 
    DefaultValue="101"/>
        </SelectParameters>
    </asp:ObjectDataSource>



    2. Do I need to specify DirectEvents to pick up any selection changes and then pass it on to the object data source?
    <ext:ComboBox ID="cbApplicationStatus" runat="server" Width="130" Editable="false" 
                  DisplayField="Status"  ValueField="Node" 
                   StoreID="storeApplicationStatusChildren"  QueryMode="Local">
        <DirectEvents>
            <Change OnEvent="cbApplicationStatus_Change"></Change>
        </DirectEvents>
    </ext:ComboBox>

    Here is the store:
    <ext:Store ID="storeApplicationStatusChildren" runat="server" DataSourceID="odsStatus">
    <Model>
        <ext:Model ID="modelApplicationStatusChildren" runat="server" IDProperty="Node">
            <Fields>
                <ext:ModelField Name="Status" Type="String" />
                <ext:ModelField Name="ParentNode" Type="Int" />
            </Fields>
        </ext:Model>
    </Model>
    </ext:Store>
    Any help is greately appricated.
    Manni
    Last edited by Daniil; Nov 05, 2012 at 3:37 PM. Reason: [CLOSED]
  2. #2

    Error binding SelectParameter to combobox SelectedItem

    After some more research and testing I have come to the conclusion that 'SelectedItem' is the correct PropertyName for the SelectParameters of the object data source. However, using the code below, I get the following error message:

    Type 'Ext.Net.ListItem' in Assembly 'Ext.Net, Version=2.1.0.21329, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87' is not marked as serializable.



    <ext:ComboBox ID="ComboBox1" runat="server" 
        QueryMode="Local" StoreID="store1" Editable="false" 
        DisplayField="Status" ValueField="Node" >
    </ext:ComboBox>
    
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
         SelectMethod="GetTest" TypeName="Test.Models.Application">
        <SelectParameters>
            <asp:ControlParameter ControlID="ComboBox1" DefaultValue="101" Name="ParentNode" 
               PropertyName="SelectedItem" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    
    
    <ext:Store ID="store1" runat="server" DataSourceID="ObjectDataSource1">
        <Model>
            <ext:Model ID="model1" runat="server" IDProperty="Node">
                <Fields>
                    <ext:ModelField Name="Status" Type="String" />
                    <ext:ModelField Name="ParentNode" Type="Int" />
                </Fields>
            </ext:Model>
        </Model>
    </ext:Store>
    Can someone from the Dev Team or Support reproduce and confirm this behavior?

    If not, where is my mistake?

    Thanks!
  3. #3
    Hi @Manni,

    Thank you for the question. We will investigate a possibility to get it working.
  4. #4
    For now we can suggest to use the ObjectDataSource Selecting event to manually manage the required parameter.
  5. #5
    Thanks, Daniil. I got it to work with the Selecting event.

    Will this issue be resolved with the next minor release?
  6. #6
    Quote Originally Posted by Manni View Post
    Will this issue be resolved with the next minor release?
    I am not sure yet. We are still investigating.
  7. #7
    Quote Originally Posted by Daniil View Post
    I am not sure yet. We are still investigating.
    Hi Daniil,
    any update on this?
    Manni
  8. #8
    I had another look at the issue and was unable to reproduce.

    Here is my test case.

    A SelectedItem property is a ListItem type. I think it is wrong to set up int type for the ControlParameter.

    Example Page
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Rebind(object sender, DirectEventArgs e)
        {
            this.Store1.DataBind();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:ComboBox ID="ComboBox1" runat="server" QueryMode="Local">
                <Items>
                    <ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
                    <ext:ListItem Text="Item 2" Value="2" Mode="Raw" />
                </Items>
                <SelectedItems>
                    <ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
                </SelectedItems>
            </ext:ComboBox>
     
            <asp:ObjectDataSource 
                ID="ObjectDataSource1" 
                runat="server"
                TypeName="Test"
                SelectMethod="GetTest">
                <SelectParameters>
                    <asp:ControlParameter 
                        ControlID="ComboBox1" 
                        Name="ParentNode"
                        PropertyName="SelectedItem" />
                </SelectParameters>
            </asp:ObjectDataSource>
     
            
            <ext:Store ID="Store1" runat="server" DataSourceID="ObjectDataSource1">
                <Model>
                    <ext:Model runat="server">
                        <Fields>
                            <ext:ModelField Name="Status" Type="String" />
                            <ext:ModelField Name="ParentNode" Type="Int" />
                        </Fields>
                    </ext:Model>
                </Model>
                <Listeners>
                    <Load Handler="App.Container1.update(records[0].data);" />
                </Listeners>
            </ext:Store>
    
            <ext:Button runat="server" Text="Re-bind" OnDirectClick="Rebind" />
    
            <ext:Container ID="Container1" runat="server">
                <Tpl>
                    <Html>
                        Status : {Status} <br/>
                        ParentNode : {ParentNode}
                    </Html>
                </Tpl>
            </ext:Container>
        </form>
    </body>
    </html>
    Test Class
    using Ext.Net;
    
    public class Test
    {
        public object[] GetTest(ListItem ParentNode)
        {
            return 
                new object[] 
                { 
                    new object[] { ParentNode.Text, int.Parse(ParentNode.Value) }
                };
        }
    }
    Last edited by Daniil; Oct 31, 2012 at 5:41 PM.
  9. #9
    Thanks Daniil. I will have to revisit this issue and will let you know.
  10. #10
    Good. Please feel free to update the thread with any new related info despite it is marked closed.

Similar Threads

  1. Replies: 4
    Last Post: Sep 28, 2011, 8:57 AM
  2. Get selected value from combobox
    By lion142 in forum 1.x Help
    Replies: 0
    Last Post: Mar 04, 2011, 12:21 AM
  3. [CLOSED] SelectBox, ComboBox and ControlParameter
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 27, 2010, 5:04 PM
  4. How to get the value selected from a comboBox?
    By flormariafr in forum 1.x Help
    Replies: 2
    Last Post: Jan 23, 2010, 3:49 PM
  5. [CLOSED] How to get the value of a CycleButton into a ControlParameter
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 17, 2009, 12:31 PM

Tags for this Thread

Posting Permissions