zoukankan
html css js c++ java
ajax笔记 显示出所城市名称 ShowCity.aspx.cs代码
下面是cs代码
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.Text;
using
GetCommand;
//
这是一个连接数据库的DLL
public
partial
class
Ajax_ShowCity : System.Web.UI.Page, ICallbackEventHandler
...
{
/**/
///
<summary>
///
声明一个数据集对象
///
</summary>
private
DataSet lookupData
=
null
;
protected
void
Page_Load(
object
sender, EventArgs e)
...
{
string
js
=
Page.ClientScript.GetCallbackEventReference(
this
,
"
arg
"
,
"
OnServerCallComplete
"
,
"
ctx
"
,
"
OnServerCallError
"
,
true
);
//
这里false表示异步回调; true表示同步回调);
StringBuilder newFunction
=
new
StringBuilder();
newFunction.Append(
"
function StartAsyncCall(arg,ctx)
"
);
newFunction.Append(
"
{
"
);
newFunction.Append( js );
newFunction.Append(
"
}
"
);
Page.ClientScript.RegisterClientScriptBlock(
this
.GetType(),
"
NewAsyncMethod
"
, newFunction.ToString(),
true
);
/**/
///
///
是首页上显示出所有城市出来
///
this
.ShowCity();
this
.lblMessage.Text
=
SetConnection._errorStatus;
this
.lblMessage.Text
+=
SetConnection.status;
}
/**/
///
<summary>
///
显示城市
///
</summary>
private
void
ShowCity()
...
{
string
executeString
=
"
select CityID,CityName from City
"
;
GridView1.DataSource
=
this
.GetLookupValuesFromDatabase(executeString,
"
City
"
);
this
.GridView1.DataBind();
}
/**/
///
<summary>
///
返回一个数据集
///
</summary>
///
<param name="executeString">
sql语句或存储过程
</param>
///
<param name="TableName">
在内存中名和名称
</param>
///
<returns>
ds
</returns>
private
DataSet GetLookupValuesFromDatabase(
string
executeString,
string
TableName)
...
{
DataSet ds
=
GetCommand.SetConnection.getDataSet(executeString, TableName);
return
ds;
}
/**/
///
<summary>
///
返回回调结果
///
</summary>
///
<returns></returns>
public
string
GetCallbackResult()
...
{
/**/
///
///
存放City表中的城市ID号
///
StringBuilder ids
=
new
StringBuilder();
/**/
///
///
存放City表中的城市名称
///
StringBuilder names
=
new
StringBuilder();
int
rowCount
=
0
;
int
numberRows
=
lookupData.Tables[
"
City
"
].Rows.Count;
foreach
(DataRow row
in
lookupData.Tables[
"
City
"
].Rows)
...
{
rowCount
++
;
if
(rowCount
<=
numberRows)
...
{
ids.Append(row[
"
CityID
"
].ToString());
ids.Append(
"
|
"
);
names.Append(row[
"
CityName
"
].ToString());
names.Append(
"
|
"
);
}
//
if (rowCount < numberRows)
//
{
//
}
}
string
returnData
=
string
.Format(
"
{0}~{1}
"
, ids.ToString(), names.ToString());
return
returnData;
}
public
void
RaiseCallbackEvent(
string
eventArgument)
...
{
System.Threading.Thread.Sleep(
2000
);
string
executeString
=
"
select CityID,CityName from City
"
;
lookupData
=
this
.GetLookupValuesFromDatabase(executeString,
"
City
"
);
}
}
下面是html里的代码
查看全文
相关阅读:
记录:将图片数据生成 tfrecords 文件并在训练使用时读取
记录:EM 算法估计混合高斯模型参数
记录:Ubuntu 18.04 安装 tensorflow-gpu 版本
记录:tf.saved_model 模块的简单使用(TensorFlow 模型存储与恢复)
记录:TensorFlow 中的 padding 方式
mybatis list映射
idea使用插件mybatis-generator-plus生成mapper文件(mysql亲测可用)
Element-UI树形表格
Mysql5.7版本ERROR 1055问题
为DISTINCT、GROUP BY和ORDER BY效率问题提提速
原文地址:https://www.cnblogs.com/xiaotuni/p/2365813.html
最新文章
排序算法之快速排序
Linux 0.11下信号量的实现和应用
在Linux-0.11中实现基于内核栈切换的进程切换
关于fork( )函数父子进程返回值的问题
服务器框架设计和技术选型
睡眠手册-《斯坦福高效睡眠法》笔记
rabbitmq 详解
ubuntu16.04 安装pptpd服务
python代码执行命令行跳过 "press any key to continue"(请键入任意值继续...)
python 构造和数据库更好关联的实体类
热门文章
Selenium添加访问cookie实现自动登录
Selenium修改PhantomJS请求头(Headers)
MySQL中数据类型介绍
排序 sort函数
彻底解决 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
LayaAir环境TypeScript
Linux配置IP
make
查、杀、启动进程
记录:测试本机下使用 GPU 训练时不会导致内存溢出的最大参数数目
Copyright © 2011-2022 走看看