public static string DataSetToJson(DataTable dt)
{
string json = string.Empty;
try
{
if (dt==null||dt.Rows.Count == 0)
{
return "";
}
json = "{";
json += "'table" + 1 + "':[";
for (int i = 0; i < dt.Rows.Count; i++)
14
2013
07
.NET DataTable转化为json格式
14
2013
07
.NET获取快递100提供的查询快递信息的方法
#region 获取快递信息
string ApiKey = "XXXXXX";//请把XXXXXX修改成您在快递100网站申请的APIKey
//string powered = "快递数据由: <a href=\"http://www.kuaidi100.com/?refer=hishop&a=e8bc69faf6f1270b\" target=\"_blank\">快递100</a> 提供";
//技术文档地址:http://code.google.com/p/kuaidi-api/wiki/Open_API_API_URL
Dictionary<string, string> dict = new Dictionary<string, string>();
switch (typeCom)
{
case "AAE全球专递":
typeCom = "aae";
break;
case "安捷快递":
typeCom = "anjiekuaidi";
break;
12
2013
07
asp.net mvc 两级分类联动方法示例
前台视图代码
<%:Html.DropDownList("AwardClassMainID","请选择")%>
<%:Html.DropDownList("SubID",new List<SelectListItem> { (new SelectListItem(){Text="请选择",Value="0"})})%>
//jquery代码
$("#AwardClassMainID").change(function () {
12
2013
07
asp.net mvc 实体类成员变量标识示例
检查不能为空
[Required]
public string ID { get; set; }
检查最大长度
06
2013
04
今天做一个网站与另外一个网站整合,学会了视图在不同数据库中的使用
1、访问不同的sql服务器的数据库表,通过一个视图使用 OPENDATASOURCE 来完成。
Create VIEW [dbo].[视图名称]
AS
Select *
FROM OPENDATASOURCE(
'SQLOLEDB',
'PWD=密码;UID=用户名;Initial Catalog=数据库名;SERVER=服务器'
16
2013
03
asp.net模版页面的高级应用
//模版页面.html
<!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> <title></title> </head> <body> <a href="#">链接1</a><br/> <a href="#" id="link2" runat="server">链接2</a><br/> <a href="#">链接3</a> </body> </html>
//Template类
16
2013
03
asp.net比较大型的企业网站的项目、目录结构问题
大型企业网站不同于一般的网站(几个页面就行了),大型网站有大量的页面,权限控制等也很复杂,为了提高开发效率,代码能有效重用,还是得注意一下项目的结构问题,不然乱开发效率是很低的,还不利于维护。
15
2013
03
06
2013
02
C# DataGrid 控件在winform里显示行号
code:
#region 行绘制事件 ,为DataGridView每行写上序号 /// <summary> /// 行绘制事件 ,为DataGridView每行写上序号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.dataGridView.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), this.dataGridView.RowHeadersDefaultCellStyle.Font, rectangle, this.dataGridView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } #endregion