The following seems to work, though it's not the best way of going about things. Are you doing something different?
Default.aspx.cs:
Code:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
//using System.Linq;
//using System.Data.Linq;
namespace ImgMap {
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
/* Oh, but for LINQ */
String dataConnStr = WebConfigurationManager.ConnectionStrings["DataConnectionString"].ConnectionString;
SqlConnection data = new SqlConnection(dataConnStr);
SqlDataAdapter query = new SqlDataAdapter("SELECT shape, coords,alt FROM dbo.Areas WHERE map='map1'", data);
DataSet mapItems = new DataSet();
query.Fill(mapItems);
shapeAreas.DataSource = mapItems;
shapeAreas.DataBind();
}
}
}
in Default.aspx:
HTML Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ImgMap._Default" %>
...
<map id="map1" name="map1">
<asp:Repeater ID="shapeAreas" runat="server">
<ItemTemplate>
<area href="#"
shape="<%# Eval("shape") %>"
coords="<%# Eval("coords") %>"
alt="<%# Eval("alt") %>"
/>
</ItemTemplate>
</asp:Repeater>
</map>
in Web.config:
HTML Code:
<connectionStrings>
<add name="DataConnectionString" connectionString="Data Source=..." providerName="System.Data.SqlClient"/>
</connectionStrings>
Table "dbo.Areas", as you can probably guess, stores the shape, coordinates, alt text and name of the associated map for every area element. If areas can appear in more than one map, the map-area relationship would be in another table, but (for the purposes of this sample) a separate table didn't appear necessary.