PDA

View Full Version : [CLOSED] DataView Bind Issue



Webezi
Jul 04, 2014, 6:47 AM
Hi,

Please run below code. If I DataBind first times, it's working. But if I fire second times, it's error.

Please Advise.



<%@ Page Language="C#" AutoEventWireup="true" %>


<!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></title>
<script runat="server">


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
stMaintenanceCategory.DataSource = new object[]
{
new {Text = "1", Value = "1"},
new {Text = "2", Value = "2"},
new {Text = "3", Value = "3"},
new {Text = "4", Value = "4"},
new {Text = "5", Value = "5"},
new {Text = "6", Value = "6"}
};
stMaintenanceCategory.DataBind();
}
}


protected void BindDataView(object sender, DirectEventArgs e)
{
stMaintenanceDetails.DataSource = new object[]
{
new {Value = "1"},
new {Value = "2"},
new {Value = "3"},
new {Value = "4"},
new {Value = "5"},
new {Value = "6"}
};
stMaintenanceDetails.DataBind();
}


</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server">
</ext:ResourceManager>
<ext:Button runat="server" Text="Bind Data View" OnDirectClick="BindDataView"></ext:Button>
<ext:Store runat="server" ID="stMaintenanceCategory">
<Model>
<ext:Model ID="Model11" runat="server">
<Fields>
<ext:ModelField Name="Text">
</ext:ModelField>
<ext:ModelField Name="Value">
</ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:DataView ID="DataView1" runat="server" DisableSelection="true">
<Store>
<ext:Store ID="stMaintenanceDetails" runat="server">
<Model>
<ext:Model ID="Model8" runat="server" Name="MaintenanceDetail">
<Fields>
<ext:ModelField Name="Value" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ItemTpl ID="ItemTpl1" runat="server">
<Html>
<tpl>
<div style="margin: 10px;">{Value}</div>
</tpl>
</Html>
</ItemTpl>
<Plugins>
<ext:ComponentView ID="ComponentView1" runat="server">
<Items>
<ext:ViewItem Value="Value" BoundField="Value">
<Component>
<ext:ComboBox ID="ComboBox1" runat="server" Width="230" DisplayField="Text" StoreID="stMaintenanceCategory"
ValueField="Value">
</ext:ComboBox>
</Component>
</ext:ViewItem>
</Items>
</ext:ComponentView>
</Plugins>
</ext:DataView>
</form>
</body>
</html>

Daniil
Jul 04, 2014, 7:54 AM
Hi @Webezi,

It appears to be working for me.


But if I fire second times, it's error.

Please always provide more information about errors.

Webezi
Jul 07, 2014, 12:59 AM
Hi Daniil,

Please see below picture, when I click the button second time, it shows the JS error

http://forums.ext.net/attachment.php?attachmentid=13341&stc=1

Daniil
Jul 07, 2014, 10:21 AM
Please specify the versions of IE and Ext.NET that you are using.

Webezi
Jul 08, 2014, 1:52 AM
I used IE11 and Ext.Net 2.5.1.24957

Daniil
Jul 08, 2014, 6:20 AM
Please try to set AutoDestroy="false" for the stMaintenanceCategory Store.

Webezi
Jul 08, 2014, 8:18 AM
It's working now. Thanks very much.