首先是页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewMap.aspx.cs" Inherits="NewMap" %>
代码
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 BLL;
public partial class NewMap : System.Web.UI.Page
{
public DataTable tb = new DataTable();
public string strmapid = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
show();
}
}
public void show()
{
string StrSql = "select * from MapXY ";
tb = DataAccess.dataSet(StrSql).Tables[0];
for(int i=0;i
int m = int.Parse(tb.Rows[i]["now"].ToString());
string l = "";
if (m >= 0 && m < 3)
{
l = "0";
}
else
{
l = "46";
}
if (tb.Rows.Count - 1 == i)
{
strmapid += "{ title: \"" + tb.Rows[i]["name"].ToString() + "\", content: \"" + tb.Rows[i]["shuoming"].ToString() + "\", point: \"" + tb.Rows[i]["x"].ToString() + "|" + tb.Rows[i]["y"].ToString() + "\", isOpen: 0, icon: { w: 23, h: 25, l: " + l + ", t: 21, x: 9, lb: 12} }";
}
else
{
strmapid += "{ title: \"" + tb.Rows[i]["name"].ToString() + "\", content: \"" + tb.Rows[i]["shuoming"].ToString() + "\", point: \"" + tb.Rows[i]["x"].ToString() + "|" + tb.Rows[i]["y"].ToString() + "\", isOpen: 0, icon: { w: 23, h: 25, l: " + l + ", t: 21, x: 9, lb: 12} },";
}
//if (tb.Rows.Count - 1 == i)
//{
// strmapid += "{ title: \"" + tb.Rows[i]["name"].ToString() + "\", content: \"" + tb.Rows[i]["shuoming"].ToString() + "\", point: \"" + tb.Rows[i]["x"].ToString() + "|" + tb.Rows[i]["y"].ToString() + "\", isOpen: 0, icon: {\"" + tb.Rows[i]["img"].ToString() + "\",new BMap.Size(300,157)} }";
//}
//else
//{
// strmapid += "{ title: \"" + tb.Rows[i]["name"].ToString() + "\", content: \"" + tb.Rows[i]["shuoming"].ToString() + "\", point: \"" + tb.Rows[i]["x"].ToString() + "|" + tb.Rows[i]["y"].ToString() + "\", isOpen: 0, icon: {\"" + tb.Rows[i]["img"].ToString() + "\",new BMap.Size(300,157)} },";
//}
//"fox.gif", new BMap.Size(300,157)
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string sqlstr = "";
sqlstr = "INSERT INTO MapXY (name,x,y,shuoming,now,address) VALUES ('" + name.Text + "','" + Request.Form["x"].ToString() + "','" + Request.Form["y"].ToString() + "','" + TextBox1.Text + "','" + DropDownList1.SelectedValue + "','" + Request.Form["address"].ToString() + "')";
DataAccess.excuteSql(sqlstr);
show();
}
}
库结构很简单 表MapXY 列 id,name,x,y,shuoming,now,address,img
仅供参考