我的ASP页面编码为GB2312,其中
<script language="javascript">
$(function() {
$('#pxxm').datagrid({
title:'请填写培训项目',
iconCls: 'icon-edit',
singleSelect: true,
idField:'id',
//fit:true,
toolbar: '#tb',
onClickRow: onClickRow,
fitColumns:true,
columns:[[ {field:'id',width:50,title:'id',hidden:true}, {field:'pxlb',width:80,align:'centre',formatter:function(value,row){
return row.productname;
},
editor:{
type:'combobox',
options:{ valueField:'peixunid', textField:'peixunleibie', url:'peixunleibie.asp', required:true
}
},title:'培训类别'},
{field:'ksrq',width:80,align:'centre',editor:{type:'datebox'},title:'开始日期'},
{field:'jsrq',width:80,align:'centre',editor:{type:'datebox'},title:'结束日期'},
{field:'pxkm',width:250,align:'centre',editor:'text',title:'培训科目'},
{field:'pxks',width:80,align:'centre',editor:'numberbox',title:'培训课时'},
{field:'skls',width:80,align:'centre',editor:'text',title:'授课老师'},
{field:'pxcj',width:80,align:'centre',editor:'numberbox',title:'培训成绩'},
{field:'zsmc',width:80,align:'centre',editor:'text',title:'证书名称'},
{field:'fzrq',width:80,align:'centre',editor:'datebox',title:'发证日期'},
{field:'bzhu',width:100,align:'centre',editor:'text',title:'备注'}
]]
});
append();
});
</script>
其中'peixunleibie.asp'为GB2312编码:
<!--#include file="inc/Config_zd.asp"-->
<%
dim ckstr
peixunleibie_setconst=split(peixunleibie_setconst,",")
num_all=ubound(peixunleibie_setconst)
tempstr=""
tempstr=tempstr&"["
for i_num=0 to num_all
ckstr=ckstr&"{"&"""peixunid"":"""&i_num&""",""peixunleibie"":"""&peixunleibie_setconst(i_num)&""""&"},"
next
tempstr=tempstr&ckstr
tempstr=left(tempstr,len(tempstr)-1)
tempstr=tempstr&"]"
response.Write ((tempstr))
%>
Config_zd.asp文件为GB2312编码。现在datagrid的下拉列表为乱码,如图:

原因就是datagrid获取的数据必须是UTF-8编码。但是我不知道这个地方怎么将response.Write ((tempstr))输出为UTF-8编码呢?谢谢指教!
------解决方案--------------------
编码和存储编码不统一造成的,不一定非要utf-8编码
记事本打开asp页面,另存为,看编码是否为ansi,而不是utf-8编码,页面meta指定为gb2312,asp页面的存储编码要ansi
------解决方案--------------------
在ASP文件上加入 response.Charset="gb2312"
------解决方案--------------------
编码不统一造成的
记得要检查以下几个方面的编码是否统一:
一、服务端的编码声明,就是类似 <%@ CODEPAGE=936 %>这样的
二、客户端的编码声明,类似<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />这样的
三、asp文件属性的编码声明,用记事本的话,就另存为时选择编码,如果使用DW的话,就修改文档属性那里修改编码