[CLOSED] Bind Store to Array in Visual Basic...

  1. #1

    [CLOSED] Bind Store to Array in Visual Basic...



    I just want to bind my combo box to a list of years, but don't seem to be doing it correctly, I think I have something not set correctly in my store. The combobox in the following example just shows blanks...

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Session("repid") = 253
            
            Dim cs As String = Helpers.Connection.ConnectionString(Request.ServerVariables("SERVER_NAME"))
            
            Dim Years(20, 1) As Integer
            Dim year As Integer = Now().Year - 10
            Dim i As Integer
            For i = 0 To 20
                Years(i, 0) = year
                Years(i, 1) = year
                year += 1
            Next       
            
            Store1.DataSource = Years
            Store1.DataBind()
            
            
            
        End Sub
        
        
      
    
    
    </script>
    
    
    </head>
    <body>
        <form id="form1" runat="server">
        
        <ext:ScriptManager ID="ScriptManager1" runat="server"></ext:ScriptManager>           
        
        <ext:Store ID="Store1" runat="server" AutoLoad="true">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="Year"/> 
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store> 
    
    
        <ext:TabPanel runat="server" Title="Goals">
            <Tabs>
                <ext:Tab ID="Tab1" runat="server" Title="Contracts" AutoHeight="true" Width="500">
                    <Body>
                        <ext:FormLayout ID="FormLayout1" runat="server" Width="500">
                            <ext:Anchor>
                                <ext:RadioGroup ID="RadioGroup1" runat="server" FieldLabel="Frequency" ColumnsNumber="1" Vertical="true">
                                    <Items>
                                        <ext:Radio runat="server" ID="RadioContractsFrequencyWeekly" FieldLabel="Weekly" Checked="false"></ext:Radio>
                                        <ext:Radio runat="server" ID="RadioContractsFrequencyMonthly" FieldLabel="Monthly" Checked="true"></ext:Radio>
                                    </Items>
                                </ext:RadioGroup>
                            </ext:Anchor>
                            <ext:Anchor>
                                <ext:ComboBox runat="server" ID="cboContractsYear" FieldLabel="Year" StoreID="Store1" ValueField="Year" DisplayField="Year">
                                </ext:ComboBox>
                            </ext:Anchor>
                            <ext:Anchor>
                                <ext:NumberField runat="server" ID="TextContractsDefaultAmount" FieldLabel="Default Amount"></ext:NumberField>
                            </ext:Anchor>
                        </ext:FormLayout>
                    </body>
                </ext:Tab>
                <ext:Tab ID="Tab2" runat="server" Title="Calls">
                </ext:Tab>
                <ext:Tab ID="Tab3" runat="server" Title="Meetings">
                </ext:Tab>
            </Tabs>
        </ext:TabPanel>
        </form>
    </body>
    </html>

    I've tried the JSON reader and the Array reader, I can do it correctly by hard coding the values with
    Store1.DataSource = New Object() { _
      New Object() {"1", "1"} _
      , New Object() {"2", "0"} _
      , New Object() {"3", "1"} _
    }
    Store1.DataBind()
    but I'd like to set the values programmatically.

    Also, one last thing, how can I get the radio buttons to look correct, right now there is a lot of white space between the radio and the label, any way to get rid of that?

    Thanks in advance...
  2. #2

    RE: [CLOSED] Bind Store to Array in Visual Basic...

    Hi,

    Two dimensional array and array of arrays are different arrays.
    For ArrayReader you need use array of arrays.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Session("repid") = 253
            
            Dim cs As String = Helpers.Connection.ConnectionString(Request.ServerVariables("SERVER_NAME"))
            
            Dim Years As Object() = New Object(20) {}
            Dim year As Integer = Now().Year - 10
            Dim i As Integer
            For i = 0 To 20
                Years(i) = new Object(){year, year}
                year += 1
            Next       
            
            Store1.DataSource = Years
            Store1.DataBind()        
            
        End Sub
  3. #3

    RE: [CLOSED] Bind Store to Array in Visual Basic...

    Hi iansriley,

    For the <ext:Radio>, you can also set the .BoxLabel property.


    Example


    <ext:Radio runat="server" ID="RadioContractsFrequencyWeekly" BoxLabel="Weekly" Checked="false"/>

    Hope this helps.


    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] Bind Store to Array in Visual Basic...



    Thanks Guys...

    please mark as [CLOSED].

Similar Threads

  1. How to save Store in a Array?
    By ascsolutions in forum 1.x Help
    Replies: 1
    Last Post: Jan 12, 2012, 6:35 AM
  2. Which store to use for 1D array of strings?
    By wexman in forum 1.x Help
    Replies: 1
    Last Post: Oct 06, 2011, 7:01 AM
  3. [CLOSED] Array property in store
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 18, 2010, 4:36 PM
  4. [CLOSED] [1.0] Ext.net.Store.remove method not accepting array
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 23, 2010, 5:08 PM
  5. Store/Array Reader truncating data
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 08, 2009, 3:20 PM

Posting Permissions