Gridpanel显示不了数据,数据读取是正常的,可以在gridpanel里看到行,但是没有数据显示,请问怎么解决! 15
<formid="form1"runat="server"><ext:ScriptManagerrunat="server"ID="sm1"></ext:ScriptMa...
<form id="form1" runat="server">
<ext:ScriptManager runat="server" ID="sm1"></ext:ScriptManager>
<div>
<ext:Store runat="server" ID="Store1">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="xwbh" />
<ext:RecordField Name="xwbt" />
<ext:RecordField Name="fbr" />
<ext:RecordField Name="bm" />
<ext:RecordField Name="fbsj" />
<ext:RecordField Name="xwnr" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:Panel ID="Panel1" runat="server" Title="新闻列表">
<Body>
<ext:GridPanel ID="GridPanel1" AutoScroll="true" AutoHeight="true" StoreID="store1" Height="700"
runat="server" Border="false" Icon="User" AutoShow="true">
<ColumnModel>
<Columns>
<ext:RowNumbererColumn Width="40">
</ext:RowNumbererColumn>
<ext:Column ColumnID="xwbh" DataIndex="xwbh" Width="60" Header="新闻编号" Align="Center" >
</ext:Column>
<ext:Column ColumnID="xwbt" DataIndex="xwbt" Width="100" Header="新闻标题" Align="Center">
</ext:Column>
<ext:Column ColumnID="fbr" DataIndex="fbr" Width="60" Header="发布人" Align="Center">
</ext:Column>
<ext:Column ColumnID="bm" DataIndex="bm" Width="50" Header="部门" Align="Center">
</ext:Column>
<ext:Column ColumnID="fbsj" DataIndex="fbsj" Width="160" Header="发布时间" Align="Center">
</ext:Column>
<ext:Column ColumnID="xwnr" DataIndex="xwnr" Width="400" Header="新闻内容" Align="Center">
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</Body>
</ext:Panel>
绑定数据的语句
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
string strSql = "select ID,title,name,depart,date,news from xwsj";
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(strSql, con);
sda.Fill(ds, "xwsj");
this.Store1.DataSource = ds;
Store1.DataBind();
con.Close(); 展开
<ext:ScriptManager runat="server" ID="sm1"></ext:ScriptManager>
<div>
<ext:Store runat="server" ID="Store1">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="xwbh" />
<ext:RecordField Name="xwbt" />
<ext:RecordField Name="fbr" />
<ext:RecordField Name="bm" />
<ext:RecordField Name="fbsj" />
<ext:RecordField Name="xwnr" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:Panel ID="Panel1" runat="server" Title="新闻列表">
<Body>
<ext:GridPanel ID="GridPanel1" AutoScroll="true" AutoHeight="true" StoreID="store1" Height="700"
runat="server" Border="false" Icon="User" AutoShow="true">
<ColumnModel>
<Columns>
<ext:RowNumbererColumn Width="40">
</ext:RowNumbererColumn>
<ext:Column ColumnID="xwbh" DataIndex="xwbh" Width="60" Header="新闻编号" Align="Center" >
</ext:Column>
<ext:Column ColumnID="xwbt" DataIndex="xwbt" Width="100" Header="新闻标题" Align="Center">
</ext:Column>
<ext:Column ColumnID="fbr" DataIndex="fbr" Width="60" Header="发布人" Align="Center">
</ext:Column>
<ext:Column ColumnID="bm" DataIndex="bm" Width="50" Header="部门" Align="Center">
</ext:Column>
<ext:Column ColumnID="fbsj" DataIndex="fbsj" Width="160" Header="发布时间" Align="Center">
</ext:Column>
<ext:Column ColumnID="xwnr" DataIndex="xwnr" Width="400" Header="新闻内容" Align="Center">
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</Body>
</ext:Panel>
绑定数据的语句
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
string strSql = "select ID,title,name,depart,date,news from xwsj";
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(strSql, con);
sda.Fill(ds, "xwsj");
this.Store1.DataSource = ds;
Store1.DataBind();
con.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询