• atwiki
  • restinpiece @ ウィキ
  • [ソースコードでtableコントロール書いて中にコントロール追加するサンプル(説明無し)]の変更点

「ソースコードでtableコントロール書いて中にコントロール追加するサンプル(説明無し)」の編集履歴(バックアップ)一覧はこちら

ソースコードでtableコントロール書いて中にコントロール追加するサンプル(説明無し)」(2008/01/31 (木) 13:54:38) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

#highlight(vb.net){{ Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim numrows As Integer Dim i As Integer Dim Row As TableRow Dim Cell As TableCell Dim RowStyle As String Dim RowBorderWidth As String Dim CellStyle As String Dim CellBorderWidth As String Dim count1 As Integer Dim count2 As Integer Dim ColumRowBackColor As Object '設定 '列のスタイル RowStyle = BorderStyle.Solid RowBorderWidth = 1 'セルのスタイル CellStyle = BorderStyle.Solid CellBorderWidth = 1 ColumRowBackColor = Drawing.Color.White '行の数を指定 numrows = 10 'ドロップダウンリストの幅 Dim DropWidth As Integer = 120 'テーブルの設定 Table1.CellPadding = 0 Table1.CellSpacing = 0 Table1.Width = 800 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'カラム列追加 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Row = New TableRow() Row.BorderStyle = RowStyle Row.BorderWidth = RowBorderWidth Row.BackColor = ColumRowBackColor '職種列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 200 '職種列の追加 Cell.Controls.Add(New LiteralControl("職種")) Row.Cells.Add(Cell) '経験列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 400 '経験列の追加 Cell.Controls.Add(New LiteralControl("経験")) Row.Cells.Add(Cell) If False Then '月給列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth '月給列の追加 Cell.Controls.Add(New LiteralControl("月給")) Row.Cells.Add(Cell) End If '人数列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 200 '人数列の追加 Cell.Controls.Add(New LiteralControl("人数")) Row.Cells.Add(Cell) 'カラム行を追加 Table1.Rows.Add(Row) '####################################################### '入力フォームの作成 '####################################################### For i = 0 To numrows - 1 '行の設定 Row = New TableRow() Row.BorderStyle = RowStyle Row.BorderWidth = RowBorderWidth '####################################################### '職種列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop1 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop1.DataSourceID = SqlDataSource1.ID Drop1.DataTextField = "名称" Drop1.DataValueField = "コード" Drop1.Width = DropWidth Drop1.ID = "drop1_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop1) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '####################################################### '経験列の設定 '####################################################### If False Then 'ドロップダウンリストのオブジェクトの作成 Dim Drop2 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop2.DataSourceID = SqlDataSource2.ID Drop2.DataTextField = "名称" Drop2.DataValueField = "コード" Drop2.Width = DropWidth Drop2.ID = "drop2_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop2) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '現在参照中の区分をインクリメント End If 'ボタンのオブジェクト作成 Dim Keikenbutton As Button = New Button 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Cell.Controls.Add(Keikenbutton) Keikenbutton.Width = "50" Keikenbutton.ID = "kbotton" Keikenbutton.Text = "詳細" If False Then '####################################################### '月給列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop3 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop3.DataSourceID = SqlDataSource3.ID Drop3.DataTextField = "名称" Drop3.DataValueField = "コード" Drop3.Width = DropWidth Drop3.ID = "drop3_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop3) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) End If '####################################################### '人数列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop4 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop4.DataSourceID = SqlDataSource4.ID Drop4.DataTextField = "名称" Drop4.DataValueField = "コード" Drop4.Width = DropWidth Drop4.ID = "drop4_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop4) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '行を追加 Table1.Rows.Add(Row) Next i End Sub }}
**コード部分 #highlight(vb.net){{ Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim numrows As Integer Dim i As Integer Dim Row As TableRow Dim Cell As TableCell Dim RowStyle As String Dim RowBorderWidth As String Dim CellStyle As String Dim CellBorderWidth As String Dim count1 As Integer Dim count2 As Integer Dim ColumRowBackColor As Object '設定 '列のスタイル RowStyle = BorderStyle.Solid RowBorderWidth = 1 'セルのスタイル CellStyle = BorderStyle.Solid CellBorderWidth = 1 ColumRowBackColor = Drawing.Color.White '行の数を指定 numrows = 10 'ドロップダウンリストの幅 Dim DropWidth As Integer = 120 'テーブルの設定 Table1.CellPadding = 0 Table1.CellSpacing = 0 Table1.Width = 800 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'カラム列追加 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Row = New TableRow() Row.BorderStyle = RowStyle Row.BorderWidth = RowBorderWidth Row.BackColor = ColumRowBackColor '職種列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 200 '職種列の追加 Cell.Controls.Add(New LiteralControl("職種")) Row.Cells.Add(Cell) '経験列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 400 '経験列の追加 Cell.Controls.Add(New LiteralControl("経験")) Row.Cells.Add(Cell) If False Then '月給列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth '月給列の追加 Cell.Controls.Add(New LiteralControl("月給")) Row.Cells.Add(Cell) End If '人数列の設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth Cell.Width = 200 '人数列の追加 Cell.Controls.Add(New LiteralControl("人数")) Row.Cells.Add(Cell) 'カラム行を追加 Table1.Rows.Add(Row) '####################################################### '入力フォームの作成 '####################################################### For i = 0 To numrows - 1 '行の設定 Row = New TableRow() Row.BorderStyle = RowStyle Row.BorderWidth = RowBorderWidth '####################################################### '職種列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop1 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop1.DataSourceID = SqlDataSource1.ID Drop1.DataTextField = "名称" Drop1.DataValueField = "コード" Drop1.Width = DropWidth Drop1.ID = "drop1_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop1) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '####################################################### '経験列の設定 '####################################################### If False Then 'ドロップダウンリストのオブジェクトの作成 Dim Drop2 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop2.DataSourceID = SqlDataSource2.ID Drop2.DataTextField = "名称" Drop2.DataValueField = "コード" Drop2.Width = DropWidth Drop2.ID = "drop2_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop2) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '現在参照中の区分をインクリメント End If 'ボタンのオブジェクト作成 Dim Keikenbutton As Button = New Button 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Cell.Controls.Add(Keikenbutton) Keikenbutton.Width = "50" Keikenbutton.ID = "kbotton" Keikenbutton.Text = "詳細" If False Then '####################################################### '月給列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop3 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop3.DataSourceID = SqlDataSource3.ID Drop3.DataTextField = "名称" Drop3.DataValueField = "コード" Drop3.Width = DropWidth Drop3.ID = "drop3_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop3) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) End If '####################################################### '人数列の設定 '####################################################### 'ドロップダウンリストのオブジェクトの作成 Dim Drop4 As DropDownList = New DropDownList 'セルごとの設定 Cell = New TableCell() Cell.BorderStyle = CellStyle Cell.BorderWidth = CellBorderWidth count1 = Table1.Rows.Count count2 = Row.Cells.Count Drop4.DataSourceID = SqlDataSource4.ID Drop4.DataTextField = "名称" Drop4.DataValueField = "コード" Drop4.Width = DropWidth Drop4.ID = "drop4_" & count1 & "_" & count2 'ドロップダウンリストの追加 Cell.Controls.Add(Drop4) 'Cell.Controls.Add(New LiteralControl("行" & count1 & "列" & count2)) 'セルを追加 Row.Cells.Add(Cell) '行を追加 Table1.Rows.Add(Row) Next i End Sub }} **default.aspx #highlight(vb.net){{ <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>無題のページ</title> </head> <body> <form id="form1" runat="server" method=post> <div> 1 構成 &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; <asp:Table ID="Table1" runat="server"> </asp:Table> 2 &nbsp;期間<br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <br /> 3&nbsp;<br /> &nbsp;<asp:Button ID="Button2" runat="server" Text="確認" />&nbsp;&nbsp;&nbsp;&nbsp; <asp:Button ID="Button1" runat="server" Text="キャンセル" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DraftConnectionString1 %>" SelectCommand="SELECT * FROM [コード名称マスタ] WHERE ([区分] = @区分)"> <SelectParameters> <asp:SessionParameter DefaultValue="1" Name="区分" SessionField="CURRENTKUBUN" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DraftConnectionString1 %>" SelectCommand="SELECT * FROM [コード名称マスタ] WHERE ([区分] = @区分)"> <SelectParameters> <asp:Parameter DefaultValue="2" Name="区分" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </div> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DraftConnectionString1 %>" SelectCommand="SELECT * FROM [コード名称マスタ] WHERE ([区分] = @区分)"> <SelectParameters> <asp:Parameter DefaultValue="3" Name="区分" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:DraftConnectionString1 %>" SelectCommand="SELECT * FROM [コード名称マスタ] WHERE ([区分] = @区分)"> <SelectParameters> <asp:Parameter DefaultValue="4" Name="区分" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </form> </body> </html> }}

表示オプション

横に並べて表示:
変化行の前後のみ表示:
人気記事ランキング
目安箱バナー