uso

雑記いろいろ
★書いてある内容に保証は一切ありません。
 ご自身で判断をしてください。

[ASP.net] グリッドで動くラジオボタンPart2

2012-03-22 08:56:14 | work
■ 作ってみた

 ・ PostBack OK
 ・ Enabled  OK(Part1はこれがだめだった・・)

参考サイト:http://codezine.jp/article/detail/840

やり方はいろいろあるから、わざわざDLL作らなくてもいいかもね。
でもいっぱい使わないとダメだからDLLしてみた。
http://asp35.com/Samples/080223VB-2.aspx


'''OverItemRadio.vb

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Imports System.Collections.Specialized


<DefaultProperty("Checked"), ToolboxData("<{0}:OverItemRadio runat=server>")> _
Public Class OverItemRadio
Inherits RadioButton

Protected Overrides Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As NameValueCollection) As Boolean
Dim result As Boolean = MyBase.LoadPostData(postDataKey, postCollection)
Dim newChecked As Boolean = postCollection(GroupName) = Me.UniqueID
If Me.Checked
<add tagPrefix="OverItemRadio" namespace="OverItemRadio" assembly="OverItemRadio"/>

 2.aspxファイルの先頭に書く↓
<%@ Register Assembly="OverItemRadio" Namespace="OverItemRadio" TagPrefix="rdo" %>

 3.Directcastで値をとったりする
    例)  DirectCast(e.Row.Cells(2).Controls(1), OverItemRadio.OverItemRadio).Checked = True

大体こんな感じ。だったかな。。