【ラジオボタンリスト型セル】「×」など特殊文字をラジオボタンのラベルに設定した場合、ポストバック後にラジオボタンのチェックがクリアされる
対象製品
SPREAD for .NET 2.5J Web Forms Edition
発生環境
動作保証環境と同様
状況
修正済み
詳細
「×」や「<」など特殊文字をラベルに設定したラジオボタンをチェックしてポストバックすると、ラジオボタンのチェックがクリアされます。
【手順】
1.新規WebフォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.A1セルで「×」のラジオボタンをチェックします
4.ボタンを押下してポストバックします
5.ラジオボタンのチェックがクリアされます
【サンプルコード】
-------------------------
Webフォームクラス
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim rdo01 As New FarPoint.Web.Spread.RadioButtonListCellType
Dim rbstr As String()
Dim rbval As String()
rbstr = New String() {"○", "×", "△"}
rbval = New String() {"1", "2", "3"}
With rdo01
.Items = rbstr
.Values = rbval
.RepeatDirection = RepeatDirection.Horizontal
End With
FpSpread1.ActiveSheetView.Columns(0).Width = 204
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = rdo01
FpSpread1.ActiveSheetView.Cells(0, 0).Value = "1"
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FpSpread1.SaveChanges()
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
【手順】
1.新規WebフォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.A1セルで「×」のラジオボタンをチェックします
4.ボタンを押下してポストバックします
5.ラジオボタンのチェックがクリアされます
【サンプルコード】
-------------------------
Webフォームクラス
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim rdo01 As New FarPoint.Web.Spread.RadioButtonListCellType
Dim rbstr As String()
Dim rbval As String()
rbstr = New String() {"○", "×", "△"}
rbval = New String() {"1", "2", "3"}
With rdo01
.Items = rbstr
.Values = rbval
.RepeatDirection = RepeatDirection.Horizontal
End With
FpSpread1.ActiveSheetView.Columns(0).Width = 204
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = rdo01
FpSpread1.ActiveSheetView.Cells(0, 0).Value = "1"
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FpSpread1.SaveChanges()
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
回避方法
2009/05/27版で修正済み。
2009/05/27版より前のバージョンでは次の回避方法が有効です。
ラジオボタンのラベルに特殊文字を使用する場合は、既存のラジオボタンリスト型セルを継承したカスタムセル型クラスを作成し、デコード処理を追加します。
【サンプルコード】
-------------------------
Webフォームクラス
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim rdo01 As New myRadioCellType
Dim rbstr As String()
Dim rbval As String()
rbstr = New String() {"○", "×", "△"}
rbval = New String() {"1", "2", "3"}
With rdo01
.Items = rbstr
.Values = rbval
.RepeatDirection = RepeatDirection.Horizontal
End With
FpSpread1.ActiveSheetView.Columns(0).Width = 204
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = rdo01
FpSpread1.ActiveSheetView.Cells(0, 0).Value = "1"
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FpSpread1.SaveChanges()
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
-------------------------
myRadioCellTypeクラス
-------------------------
Public Class myRadioCellType
Inherits FarPoint.Web.Spread.RadioButtonListCellType
Public Overrides Function PaintCell(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
Dim rl As RadioButtonList
rl = CType(MyBase.PaintCell(id, parent, style, margin, value, upperLevel), RadioButtonList)
If Not value Is Nothing Then
rl.SelectedValue = HttpUtility.HtmlDecode(value.ToString())
End If
Return rl
End Function
End Class
2009/05/27版より前のバージョンでは次の回避方法が有効です。
ラジオボタンのラベルに特殊文字を使用する場合は、既存のラジオボタンリスト型セルを継承したカスタムセル型クラスを作成し、デコード処理を追加します。
【サンプルコード】
-------------------------
Webフォームクラス
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim rdo01 As New myRadioCellType
Dim rbstr As String()
Dim rbval As String()
rbstr = New String() {"○", "×", "△"}
rbval = New String() {"1", "2", "3"}
With rdo01
.Items = rbstr
.Values = rbval
.RepeatDirection = RepeatDirection.Horizontal
End With
FpSpread1.ActiveSheetView.Columns(0).Width = 204
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = rdo01
FpSpread1.ActiveSheetView.Cells(0, 0).Value = "1"
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FpSpread1.SaveChanges()
Button1.Text = "A1 cell value:" + FpSpread1.ActiveSheetView.Cells(0, 0).Value.ToString()
End Sub
-------------------------
myRadioCellTypeクラス
-------------------------
Inherits FarPoint.Web.Spread.RadioButtonListCellType
Public Overrides Function PaintCell(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
Dim rl As RadioButtonList
rl = CType(MyBase.PaintCell(id, parent, style, margin, value, upperLevel), RadioButtonList)
If Not value Is Nothing Then
rl.SelectedValue = HttpUtility.HtmlDecode(value.ToString())
End If
Return rl
End Function
End Class
キーワード
SPRN07052
この文書は、以前は次のバグレポートIDで公開されていました : 7779