txizsy2011 你好,
1.左下角按钮对应事件为 “FpSpread1_UpdateCommand”。
2.当有 “FpSpread1_DataBinding“ 事件时,每次重新加载页面都会调用。
3.可以通过自定义 FpSpread1.CallBack("MyCommand") 调用 FpSpread1_ButtonCommand 事件,执行检验过程,再通过点击 UpDateCommand 事件操作数据库。改变的单元格值,可以通过前台赋值给 ASP.NET HiddenField1 控件,再到后台取。代码如下:
前台:
- <script language="javascript" type="text/javascript" id="FpSpread1_Script0">
- function FpSpread1_DataChanged(event){
- //Add code to handle your event here.
- var change = event.cellValue;
- var col = FpSpread1.ActiveCol;
- var row = FpSpread1.ActiveRow;
- var test = document.getElementById("HiddenField1");
- test.value = change;
- FpSpread1.UpdatePostbackData();
- //调用 FpSpread1_ButtonCommand
- FpSpread1.CallBack("MyCommand"+","+row.toString()+","+col.toString());
- }
- </script>
复制代码 后台:
- protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- //操作数据库
- }
- protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- //校验数据
- //HiddenField1 取到改变值
- }
复制代码 |