找回密码
 立即注册

QQ登录

只需一步,快速开始

guangyuxuan

中级会员

2

主题

7

帖子

789

积分

中级会员

积分
789

活字格认证

最新发帖
guangyuxuan
中级会员   /  发表于:2013-7-3 16:59  /   查看:8370  /  回复:8
您好,我是Spread 7.0的用户,在控件试用中我发现两个问题需要不知道怎么解决,
第一个问题:在后台获取某个单元格在客户端输入的值
下面是我定义表格样式的代码

  1. //填充基础数据
  2. sheet.RowCount = 7;
  3. sheet.ColumnCount = 2;
  4. //设置表格基础样式
  5. InitCellTypes(sheet);
  6. sheet.Cells[0, 0].Text = "单位名称:";
  7. sheet.Cells[1, 0].Text = "单位地址:";
复制代码

前台展现的为
QQ截图20130703165517.png
我想实现的是,用户在输入内容后点击保存按钮,在后台用this.Fp.Sheets[0].Cells[1, 1].Text.ToString();取值,但是取出的值是null,
用this.Fp.Sheets[0].Cells[1, 1].value.ToString();取值,取出的是“”,不知道是什么原因

第二个问题:ComboBoxCell在选中值改变后,怎么能触发后台事件?

8 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-7-3 17:33:00
沙发
回复 1楼guangyuxuan的帖子

请使用以下代码测试:

  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             FarPoint.Web.Spread.ComboBoxCellType c = new FarPoint.Web.Spread.ComboBoxCellType(new String[] { "One", "Two", "Three" });

  8.             //设置 autopostback 属性,调用FpSpread1_ButtonCommand事件
  9.             c.AutoPostBack = true;
  10.             c.ShowButton = true;
  11.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = c;

  12.             
  13.         }

  14.         protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  15.         {

  16.         }

  17.         protected void Button1_Click(object sender, EventArgs e)
  18.         {
  19.             //首先保存 Spread ,再取值
  20.             this.FpSpread1.SaveChanges();

  21.             string text = this.FpSpread1.Sheets[0].Cells[this.FpSpread1.Sheets[0].ActiveRow, this.FpSpread1.Sheets[0].ActiveColumn].Text;
  22.             string value = this.FpSpread1.Sheets[0].Cells[this.FpSpread1.Sheets[0].ActiveRow, this.FpSpread1.Sheets[0].ActiveColumn].Value.ToString();
  23.         }
复制代码
回复 使用道具 举报
guangyuxuan
中级会员   /  发表于:2013-7-4 09:19:00
板凳
回复 2楼iceman的帖子

您好,我已经根据您的代码进行了测试,可是在SaveChanges()后依然不能取到Cells里面的值,不知道是不是因为我把Spread控件套在了ext的<Content>中?这是我的代码
<extanel ID="anel1" runat="server" Margins="5" Region="Center" BodyPadding="10">
               <Content>
                    <FarPoint:FpSpread id="EnterpriseInfoList" runat="server" BorderStyle="Solid" BorderWidth="1px"
                        Height="600px" Width="400px" ActiveSheetViewIndex="0" currentPageIndex="0" ClientAutoSize="True">
                        <commandbar buttonshadowcolor="ControlDark" buttonfacecolor="Control" buttonhighlightcolor="ControlLightLight"
                            backcolor="Control">
                        </commandbar>
                        <sheets>
                          <FarPoint:SheetView SheetName="工业数据编辑"></FarPoint:SheetView>
                        </sheets>
                    </FarPoint:FpSpread>
         </Content>
</extanel>

另外对于 protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)这个方法是在哪注册的?我查了Spread属性里面的事件并没有找到ButtonCommand
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-7-4 11:05:00
地板
回复 3楼guangyuxuan的帖子

guangyuxuan 你好,

请参考我的 Demo :

9620.zip (14.37 KB, 下载次数: 966)
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-7-4 11:07:00
5#
1.嵌套在 Panel 中不会影响取值,如果问题没有解决,请把你的 Demo发到论坛测试。
2.FpSpread1_ButtonCommand 为后天事件,可以同以下代码添加:

  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             this.FpSpread1.ButtonCommand+=new FarPoint.Web.Spread.SpreadCommandEventHandler(FpSpread1_ButtonCommand);

  8.             
  9.         }

  10.         protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  11.         {

  12.         }
复制代码
回复 使用道具 举报
guangyuxuan
中级会员   /  发表于:2013-7-5 10:20:00
6#
回复 5楼iceman的帖子

您好,我已经用您的例子测试过了,功能可以实现,但是把Spread套在Ext.net控件里面确实取不到cell里面的值。有可能是控件直接不兼容吧?
另外在执行FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)事件的时候我怎么能取到所做操作行的的行号,或者直接取到所操作下拉列表里面的选择的值呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-7-5 11:57:00
7#
回复 6楼guangyuxuan的帖子

关于问题一,能否发个 Demo 上来查看呢?

问题二,请参考:点击进入
回复 使用道具 举报
guangyuxuan
中级会员   /  发表于:2013-7-10 16:12:00
8#
回复 7楼iceman的帖子

您好,请问您有邮箱吗?我把demo给您发过去,论坛上限制大小,传不上去
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-7-10 16:18:00
9#
回复 8楼guangyuxuan的帖子

如果您把 bin 目录删除还会超过大小限制吗?我把我的邮箱通过站内信的形式发送给您。请注意查收。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部