SqlDataSource can't display Chinese characters

  1. #1

    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:
    Click image for larger version. 

Name:	Problem.JPG 
Views:	1093 
Size:	48.2 KB 
ID:	2694

    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>
  2. #2
    Hi,

    Is it CNAME date?
    DateColumn can work with date only.
    Please replace DateColumn by Column
  3. #3
    It's nvarchar data type in mssql2008. CNAME is Chinese Name.
  4. #4
    for Nan issue I found my mistake, I use <ext:DateColumn instead of <ext:Column.
    But the first column, all data will along with undefined String behind. What's wrong with it?
  5. #5
    Is there anyone can help me to solve this problem? The "undefined" characters along with the data.
  6. #6
    I changed the secquence for first column and second column in ColumnModel. I found the first column always have undefined String. Finally I solved the problem, It's the View problem. These code cause the undefined data String. I just remove it. I just copy the exsample codes...
    <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>

Similar Threads

  1. Replies: 0
    Last Post: Dec 17, 2011, 9:48 AM
  2. Replies: 3
    Last Post: Sep 08, 2011, 5:38 AM
  3. Replies: 1
    Last Post: Jun 21, 2011, 5:22 AM
  4. Help,Desktop BUG in V1.0,From Chinese?
    By songyecc in forum 1.x Help
    Replies: 0
    Last Post: Sep 29, 2010, 7:02 AM
  5. Chinese garbled
    By mengfb in forum 1.x Help
    Replies: 0
    Last Post: Jun 05, 2009, 2:47 AM

Tags for this Thread

Posting Permissions