How to use new databinding for sql datasource ?

  1. #1

    How to use new databinding for sql datasource ?

    How to use new databinding for sqldatasource and store ?
  2. #2
    Hello,

    Maybe the following sample can help, see

    https://examples3.ext.net/#/GridPane...SqlDataSource/
    Geoffrey McGill
    Founder
  3. #3
    hi.

    <head runat="server">
        <title></title>
    
        <script runat="server">
            public class MyModel
            {
                public static object Model = new
                {
                    stores = new
                    {
                        customers = new
                        {
                            model = "Customer",
                            autoLoad = true,
                            session = true
                        }
                    }
                };
            }
    
        </script>
    
    </head>
    
    <ext:Store runat="server" ID="storeBirimTur" DataSourceID="sdsBirimTur" AutoLoad="true">
                <Proxy>
                    <ext:PageProxy />
                </Proxy>
    
                <Model>
                    <ext:Model runat="server" Name="Customer" IDProperty="gnl_birimler_tur_id">
                        <Fields>
                            <ext:ModelField Name="gnl_birimler_tur_id" Type="String" />
                            <ext:ModelField Name="grubu_kod" />
                            <ext:ModelField Name="grubu" />
                            <ext:ModelField Name="sinifi_kod" />
                            <ext:ModelField Name="sinifi" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
    
            <ext:Panel ID="View1" runat="server" 
                Title="All Customers"
                ReferenceHolder="true"
                Frame="true"
                Width="420"
                Height="320"
                Session="true"
                ViewModel="<%# MyModel.Model %>" 
                AutoDataBind="true">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
               <Items>
                   <ext:GridPanel runat="server"
                       BindString="{customers}"
                       Reference="customerGrid"
                       Flex="1">
                       <ColumnModel>
                           <Columns>
                               <ext:Column runat="server" 
                                   Text="gnl_birimler_tur_id" 
                                   DataIndex="gnl_birimler_tur_id" 
                                   Flex="1" />
                               <ext:Column runat="server" 
                                   Text="grubu_kod" 
                                   DataIndex="grubu_kod"
                                   Width="115" />
                           </Columns>
                       </ColumnModel>
                   </ext:GridPanel>
               </Items>
            </ext:Panel>
    error img
    Attached Thumbnails Click image for larger version. 

Name:	error.png 
Views:	35 
Size:	72.7 KB 
ID:	18271  
    Last edited by geoffrey.mcgill; Jan 05, 2015 at 10:10 PM. Reason: Please use [CODE] tags
  4. #4

    WebConfig

    Hi @siyahgul

    Your web config file is probably not set properly. Please check "IV. SAMPLE WEB.CONFIG" section in this link
    https://examples3.ext.net/examples/G...uments/README/
  5. #5
    Siyahgul, you're using a PageProxy, with no config when you were supposed to bind Store's DataSourceID to a SqlDataSource, as shown on https://examples3.ext.net/#/GridPane...SqlDataSource/
  6. #6
    Siyahgul, the image that you posted is not the actual error message. Running your example we get the following error: A IDatasource Control with the ID 'sdsBirimTur' could not be found.
  7. #7
    So, need to add sdsBirimTur SqlDataSource, as shown below (Example):
    <asp:SqlDataSource ID="sdsBirimTur" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                        SelectCommand="
                        SELECT 
                        [EmployeeID], 
                        [LastName], 
                        [FirstName], 
                        [Title], 
                        [TitleOfCourtesy], 
                        [BirthDate], 
                        [HireDate], 
                        [Address], 
                        [City], 
                        [Region], 
                        [PostalCode], 
                        [Country], 
                        [HomePhone], 
                        [Extension], 
                        [Notes] 
                        FROM [Employees]" />
    For more information: https://examples3.ext.net/#/GridPane...SqlDataSource/
  8. #8
    hi everbody. Thank you for your answer.

    https://examples3.ext.net/#/Data_Binding/Basic/Two_Way/

    I want to do the following example of "store" and "SqlDataSource" to adapt.

    <head runat="server">
        <title></title>
     
        <script runat="server">
            public class MyModel
            {
                public static object Model = new
                {
                    stores = new
                    {
                        customers = new
                        {
                            model = "Customer",
                            autoLoad = true,
                            session = true
                        }
                    }
                };
            }
     
        </script>
     
    </head>
    
    <body style="background-color: #c0c0c0">
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server">
            </ext:ResourceManager>
            
    <ext:Store runat="server" ID="storeBirimTur" DataSourceID="sdsBirimTur" AutoLoad="true">
                <Proxy>
                    <ext:PageProxy />
                </Proxy>
     
                <Model>
                    <ext:Model runat="server" Name="Customer" IDProperty="gnl_birimler_tur_id">
                        <Fields>
                            <ext:ModelField Name="gnl_birimler_tur_id" Type="String" />
                            <ext:ModelField Name="grubu_kod" />
                            <ext:ModelField Name="grubu" />
                            <ext:ModelField Name="sinifi_kod" />
                            <ext:ModelField Name="sinifi" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
     
            <ext:Panel ID="View1" runat="server"
                Title="All Customers"
                ReferenceHolder="true"
                Frame="true"
                Width="420"
                Height="320"
                Session="true"
                ViewModel="<%# MyModel.Model %>" 
                AutoDataBind="true">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
               <Items>
                   <ext:GridPanel runat="server"
                       BindString="{customers}"
                       Reference="customerGrid"
                       Flex="1">
                       <ColumnModel>
                           <Columns>
                               <ext:Column runat="server"
                                   Text="gnl_birimler_tur_id"
                                   DataIndex="gnl_birimler_tur_id"
                                   Flex="1" />
                               <ext:Column runat="server"
                                   Text="grubu_kod"
                                   DataIndex="grubu_kod"
                                   Width="115" />
                           </Columns>
                       </ColumnModel>
                   </ext:GridPanel>
               </Items>
            </ext:Panel>
    
    <asp:SqlDataSource ID="sdsBirimTur" runat="server" ConnectionString="<%$ ConnectionStrings:test %>" SelectCommand="SELECT gnl_birimler_tur_id, grubu, grubu_kod, sinifi, sinifi_kod FROM gnl_birimler_tur ORDER BY grubu, sinifi">
            </asp:SqlDataSource>
    </form>
    </body>
    error img
    Click image for larger version. 

Name:	error.png 
Views:	4 
Size:	72.7 KB 
ID:	18532

Similar Threads

  1. CheckboxGroup Databinding?
    By Tbaseflug in forum 2.x Help
    Replies: 1
    Last Post: Jul 18, 2012, 10:47 PM
  2. 2 Way Databinding
    By darrenarbell in forum 2.x Help
    Replies: 0
    Last Post: Apr 16, 2012, 11:00 PM
  3. Replies: 5
    Last Post: Feb 01, 2012, 11:54 AM
  4. [CLOSED] ComboBox / Store / DataSource : Store.DataSource is NULL
    By wagger in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 24, 2011, 10:09 AM
  5. Datefield databinding
    By Kamal in forum 1.x Help
    Replies: 1
    Last Post: Jan 06, 2010, 8:47 PM

Tags for this Thread

Posting Permissions