如果您需要不用每次手动点击保存spread数据,可以做如下修改,再点击按钮自动提交所有spread修改。
- <form id="form1" runat="server">
- <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="updateSpreads()" />
- </form>
- <script>
- function updateSpreads() {
- <% for (int i = 0; i < this.spreadsIDs.Count; i++) %>
- <% { Response.Write(this.spreadsIDs[i] + ".Update();"); }%>
- }
- </script>
复制代码
- public List<string> spreadsIDs { get; set; }
- protected void Page_Load(object sender, EventArgs e)
- {
- spreadsIDs = new List<string>();
- var list = new string[3] { "spread1", "spread2", "spread3" };
- for (int i = 0; i < list.Length; i++)
- {
- var spread = new FarPoint.Web.Spread.FpSpread();
- spread.Open(Server.MapPath("template.xml"));
- spread.Height = 300;
- spread.ActiveSheetView.Cells[0, 0].Value = list[i];
- form1.Controls.Add(spread);
- spreadsIDs.Add(spread.ClientID);
- }
- }
复制代码 |