Aug 01, 2013, 2:19 AM
[CLOSED] very strange null reference exception?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm8.aspx.cs" Inherits="TobrosCWT.pages.pingzheng.WebForm8" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<script runat="server">
public class Company
{
public int ID { get; set; }
public string Name { get; set; }
}
public List<Company> GetData()
{
return new List<Company>
{
new Company{ID = 1,Name = "comp1"},
new Company{ID = 2,Name = "comp2"},
};
}
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.BindData();
}
}
private void BindData()
{
this.store1.DataSource = GetData();
this.store1.DataBind();
}
protected void clickme(object sender, DirectEventArgs e)
{
this.cc_bz.Show();
}
</script>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server"></ext:ResourceManager>
<ext:GridPanel runat="server" ID="gridpanel1" Height="100">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="show the column">
<DirectEvents>
<Click OnEvent="clickme"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ext:Store>
<ext:Store runat="server" ID="store1">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</ext:Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column runat="server" DataIndex="ID" Text="ID"></ext:Column>
<ext:Column ID="Column1" runat="server" DataIndex="Name" Text="NAME"></ext:Column>
<ext:ComponentColumn Hidden="true" ID="cc_bz" runat="server" Align="Right" Text="币别" DataIndex="bizhong" Editor="True" Width="230">
<Component>
<ext:Container ID="Container3" runat="server" Layout="HBoxLayout">
<Items>
<ext:ComboBox ID="ComboBox1" runat="server" ItemID="Currency" InputWidth="60">
<Items>
<ext:ListItem Text="USD" Value="1" Mode="Raw" />
<ext:ListItem Text="EURO" Value="2" Mode="Raw" />
</Items>
</ext:ComboBox>
<ext:TextField runat="server" InputWidth="60"></ext:TextField>
<ext:TextField runat="server" FieldLabel="原币" LabelWidth="40" InputWidth="50"></ext:TextField>
</Items>
</ext:Container>
</Component>
</ext:ComponentColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>
this.store1 throws null reference exception, but I have defined the store1 in the gridpanel, why?
Last edited by Daniil; Aug 06, 2013 at 9:28 AM.
Reason: [CLOSED]