Haha, valid only for IE :)
Front-end code: <% @ 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 = "server">
<Title> No title page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div style = "width: 600px; Height: 400px;" id = "div1">
<Asp: gridview id = "gridview1" runat = "server" Height = "300px" width = "200px">
</ASP: gridview>
& Nbsp; </div>
<Script language = "JavaScript" type = "text/JavaScript">
Document. getelementbyid ("div1"). contenteditable = true;
Document.exe ccommand ('2d-position', true, true );
</SCRIPT>
</Form>
</Body>
</Html>
Background code: using system;
Using system. Data;
Using system. configuration;
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;
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Gridview1.style. Add ("position", "absolute ");
Gridview1.datasource = getdataset ();
Gridview1.datamember = "testtable ";
Gridview1.databind ();
}
}
Private dataset getdataset ()
{
Datatable dt = new datatable ("testtable ");
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;
For (INT I = 0; I <10; I ++)
{
Dr = DT. newrow ();
Dr [0] = I;
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 );
Return Ds;
}
}