呵呵, 仅IE有效:)
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="servidor">
<title>无标题页</title>
</head>
<corpo>
<form id="form1" runat="servidor">
<div style="largura:600px;altura:400px;" id="div1">
<asp:GridView ID="GridView1" runat="servidor" Height="300px" Width="200px">
</asp:GridView>
</div>
<linguagem script="javascript" type="text/javascript">
document.getElementById("div1").contentEditable = true;
document.execCommand('Posição 2D', true, true);
</script>
</form>
</body>
</html>后台代码:
usando o sistema;
usando System.Data;
usando System.Configuration;
usando System.Web;
usando System.Web.Security;
usando System.Web.UI;
usando System.Web.UI.WebControls;
usando System.Web.UI.WebControls.WebParts;
usando System.Web.UI.HtmlControls;
classe parcial pública _Default: System.Web.UI.Page
{
protegido void Page_Load (remetente do objeto, EventArgs e)
{
se (!IsPostBack)
{
GridView1.Style.Add("posição", "absoluto");
GridView1.DataSource = GetDataSet();
GridView1.DataMember = "tabela de teste";
GridView1.DataBind();
}
}
DataSet privado GetDataSet()
{
DataTable dt = new DataTable("tabelateste");
dt.Columns.Add("Col1", typeof(int));
dt.Columns.Add("Col2", typeof(string));
dt.Columns.Add("Col3", typeof(string));
dt.Columns.Add("Col4", typeof(string));
DataRow dr;
para (int i = 0; i < 10; i++)
{
dr = dt.NewRow();
dr[0] = eu;
dr[1] = "Val" + i.ToString();
dr[2] = "Val" + i.ToString();
dr[3] = "Val" + i.ToString();
dt.Rows.Add(dr);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
retornar ds;
}
}
http://luoboqingcai.cnblogs.com/archive/2006/07/01/440514.html