May 09, 2011, 4:24 PM
SqlDataSource can't display Chinese characters
I have a MSSql2008 database data source with one employee table.
I tried to follow the gridpanel examples to build one page.
Finally I did it. But some Chinese characters can't display it's becoming to "NaN/NaN/0NaN"
And I found even department english column it'll bring me some "undefined" data displayed. I tried to set the Locale to zh-CN, but it doesn't work.
I think it maybe the JSon problem. But I can't found JSon encoding settings.
Could anyone help me?
Here is the picture:
And code:
I tried to follow the gridpanel examples to build one page.
Finally I did it. But some Chinese characters can't display it's becoming to "NaN/NaN/0NaN"
And I found even department english column it'll bring me some "undefined" data displayed. I tried to set the Locale to zh-CN, but it doesn't work.
I think it maybe the JSon problem. But I can't found JSon encoding settings.
Could anyone help me?
Here is the picture:
And code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" Locale="zh-CN">
</ext:ResourceManager>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ACE_SUGGESTION;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [DEPT], [EMPID], [ENAME], [CNAME], [EXT], [MOBILE], [GROUPV], [DIRECTTEL], [EMAIL] FROM [Employee]">
</asp:SqlDataSource>
<ext:GridPanel ID="GridPanel1" Title="Employees" Frame="True" runat="server" Height="600">
<Store>
<ext:Store ID="Store1" runat="server" DataSourceID="SqlDataSource1">
<Reader>
<ext:JsonReader IDProperty="EmployeeID">
<Fields>
<ext:RecordField Name="DEPT">
</ext:RecordField>
<ext:RecordField Name="EMPID">
</ext:RecordField>
<ext:RecordField Name="ENAME">
</ext:RecordField>
<ext:RecordField Name="CNAME">
</ext:RecordField>
<ext:RecordField Name="EXT">
</ext:RecordField>
<ext:RecordField Name="MOBILE">
</ext:RecordField>
<ext:RecordField Name="GROUPV">
</ext:RecordField>
<ext:RecordField Name="DIRECTTEL">
</ext:RecordField>
<ext:RecordField Name="EMAIL">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column DataIndex="DEPT" Header="部门" Width="150" />
<ext:Column DataIndex="EMPID" Header="EmployeeID" Width="150" />
<ext:Column DataIndex="ENAME" Header="English Name" Width="150" />
<ext:DateColumn DataIndex="CNAME" Header="Chinese Name" Width="110" />
<ext:DateColumn DataIndex="EXT" Header="Extension Nr" Width="110" />
<ext:Column DataIndex="MOBILE" Header="Mobile Phone" Width="150" />
<ext:Column DataIndex="GROUPV" Header="GROUPV" Width="100" />
<ext:Column DataIndex="DIRECTTEL" Header="Direct Line" Width="100" />
<ext:Column DataIndex="EMAIL" Header="EMAIL" Width="100" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" EnableRowBody="true">
<GetRowClass Handler="rowParams.body = '<p>' + record.data.Notes + '</p>'; return 'x-grid3-row-expanded';" />
</ext:GridView>
</View>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
</ext:GridPanel>
</div>
</form>
</body>
</html>