chcchb 你好,
测试环境:vs 2010 + Spread for ASP.NET 5.0
1.初始化类型为 RadioButtonListCellType 单元格值,可以使用 读取的数据的值 设置该单元格的 Value 进行初始化。测试代码:
- FarPoint.Web.Spread.RadioButtonListCellType rbl = new FarPoint.Web.Spread.RadioButtonListCellType();
- FarPoint.Web.Spread.ListItem[] items = new FarPoint.Web.Spread.ListItem[2];
- FarPoint.Web.Spread.ListItem item = new FarPoint.Web.Spread.ListItem();
- item.Text = "A";
- item.Value = "1";
- items[0] = item;
- item = new FarPoint.Web.Spread.ListItem();
- item.Text = "B";
- item.Value = "2";
- items[1] = item;
- rbl.ListItems = items;
- FpSpread1.ActiveSheetView.Cells[0, 0].CellType = rbl;
- FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
复制代码 2.可以设置 RadioButtonListCellType 的 OnCilentClick 属性去挂前台方法,在该方法中 Post 到后台 UpdateCommand 事件中,测试代码:
前台:- <script type="text/javascript">
- function selectchange() {
- var spread = this.document.getElementById("FpSpread1");
- spread.UpdatePostbackData();
- spread.CallBack("Update");
- }
- </script>
复制代码 后台:
- protected void Page_Load(object sender, EventArgs e)
- {
- FarPoint.Web.Spread.RadioButtonListCellType rbl = new FarPoint.Web.Spread.RadioButtonListCellType();
- //这里调用前台方法
- rbl.OnClientClick = "selectchange();return false";
- FarPoint.Web.Spread.ListItem[] items = new FarPoint.Web.Spread.ListItem[2];
- FarPoint.Web.Spread.ListItem item = new FarPoint.Web.Spread.ListItem();
- item.Text = "A";
- item.Value = "1";
- items[0] = item;
- item = new FarPoint.Web.Spread.ListItem();
- item.Text = "B";
- item.Value = "2";
- items[1] = item;
- rbl.ListItems = items;
- FpSpread1.ActiveSheetView.Cells[0, 0].CellType = rbl;
- FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
- FarPoint.Web.Spread.CheckBoxCellType check = new FarPoint.Web.Spread.CheckBoxCellType();
- check.OnClientClick = "selectchange()";
- FpSpread1.Sheets[0].Cells[1, 1].CellType = check;
- }
- protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- }
复制代码 |