PDA

View Full Version : How to use new databinding for sql datasource ?



siyahgul
Jan 05, 2015, 7:39 PM
How to use new databinding for sqldatasource and store ?

geoffrey.mcgill
Jan 05, 2015, 9:03 PM
Hello,

Maybe the following sample can help, see

http://examples.ext.net/#/GridPanel/DataSource_Controls/SqlDataSource/

siyahgul
Jan 05, 2015, 9:31 PM
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
http://forums.ext.net/attachment.php?attachmentid=18271&stc=1

isozworld
Jan 07, 2015, 1:31 PM
Hi @siyahgul

Your web config file is probably not set properly. Please check "IV. SAMPLE WEB.CONFIG" section in this link
http://examples.ext.net/examples/Getting_Started/Release_Documents/README/

RaphaelSaldanha
Jan 07, 2015, 7:30 PM
Siyahgul, you're using a PageProxy, with no config when you were supposed to bind Store's DataSourceID to a SqlDataSource, as shown on http://examples.ext.net/#/GridPanel/DataSource_Controls/SqlDataSource/

RaphaelSaldanha
Jan 07, 2015, 7:38 PM
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.

RaphaelSaldanha
Jan 07, 2015, 7:42 PM
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: http://examples.ext.net/#/GridPanel/DataSource_Controls/SqlDataSource/

siyahgul
Jan 08, 2015, 10:45 AM
hi everbody. Thank you for your answer.

http://examples.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
18532