<frameset rows="*,*">
<frame name="top" src="WebForm1.aspx">
<frame name="bottom" src="WebForm2.aspx">
<noframes>
■WebForm1.aspx
…
<form id="Form1" method="post" runat="server">
<FONT face="MS UI Gothic">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 7px; POSITION: absolute; TOP: 7px" runat="server">
<Columns>
<asp:ButtonColumn Text="選択" ButtonType="PushButton" HeaderText="選択" CommandName="Select"></asp:ButtonColumn>
</Columns>
</asp:DataGrid></FONT>
</form>
…
■WebForm1.aspx.vb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim dt As DataTable = New DataTable
dt.Columns.Add("Fild1", GetType(String))
dt.Columns.Add("Fild2", GetType(String))
dt.Columns.Add("Fild3", GetType(String))
dt.Columns.Add("Fild4", GetType(String))
For i As Integer = 1 To 10
dt.Rows.Add(New String() {i.ToString(), "a" + i.ToString(), "b" + i.ToString(), "c" + i.ToString()})
Next
Me.DataGrid1.DataSource = dt
Me.DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
If e.CommandName = "Select" Then
Dim row As DataGridItem = e.Item
Session("myKey") = row.Cells(1).Text
Response.Write("<script language='JavaScript'>parent.bottom.location.reload();</Script>")
End If
End Sub
■WebForm2.aspx.vb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
If Not Session("myKey") Is Nothing Then
Dim dt As DataTable = New DataTable
dt.Columns.Add("Fild1", GetType(String))
dt.Columns.Add("Fild2", GetType(String))
dt.Columns.Add("Fild3", GetType(String))
dt.Columns.Add("Fild4", GetType(String))
For i As Integer = 1 To 10
dt.Rows.Add(New String() {i.ToString(), "d" + i.ToString(), "e" + i.ToString(), "f" + i.ToString()})
Next
Dim dtv As DataView = New DataView(dt, "Fild1 = '" + CType(Session("myKey"), String) + "'", "", DataViewRowState.CurrentRows)
Me.DataGrid1.DataSource = dtv
Me.DataGrid1.DataBind()
End If
End If
End Sub
|