- PR -

【ASP.NET】ページ遷移(フレーム)

1
投稿者投稿内容
homes
常連さん
会議室デビュー日: 2002/08/06
投稿数: 38
投稿日時: 2005-10-31 11:49
お世話になります。
上下分割フレームセットを作成しまして、
上側:A.aspx (Grid A)
下側:B.aspx (Grid B)
があります。
やりたい事は Grid A で表示したデータの品番をクリックすると
下側の Grid B に詳細情報を表示したいのです。
しかし、最初はフレームで表示されている様に見えるのですが、
Grid A に表示させる値を抜き出すと、A.aspxだけが独立して表示されます。

過去のログを参考にして、いろいろやっているのですが、思った通りの
動きをしてくれません。

データの値の受け渡しはSessionを使用し、Server.Transferで遷移すると
いった手法を使っております。
Grid B に表示される結果としては合っていたのでデータの受け渡しは
出来ていると思います。

後は過去のログを参考にして A.aspx に target=_top を記述しております。
Server.Transfer("wfmB.aspx?state=1",True)
ここが問題なのでしょうか。
環境はWinXP ASP.NET(VB)です。
よろしくお願いします。
なおこ(・∀・)
大ベテラン
会議室デビュー日: 2004/04/08
投稿数: 174
お住まい・勤務地: 東京都
投稿日時: 2005-10-31 12:38
お世話になります。

こんな感じはいかがでしょうか。
コード:
<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

homes
常連さん
会議室デビュー日: 2002/08/06
投稿数: 38
投稿日時: 2005-10-31 13:15
さっそくの返信ありがとうございます。
Response.Write("<script language='JavaScript'>parent.bottom.location.reload();</Script>")
ありがとうございます。
Server.Transferを上に書き換えると上手く動作しました。
この構文の解釈としてはフレームセットの【bottom】にあるページを更新すると
いった物でしょうか?
なおこ(・∀・)
大ベテラン
会議室デビュー日: 2004/04/08
投稿数: 174
お住まい・勤務地: 東京都
投稿日時: 2005-10-31 14:02
お世話になります。

引用:

homesさんの書き込み (2005-10-31 13:15) より:
この構文の解釈としてはフレームセットの【bottom】にあるページを更新すると
いった物でしょうか?



更新というか、リロードしています。
homes
常連さん
会議室デビュー日: 2002/08/06
投稿数: 38
投稿日時: 2005-10-31 16:52
そうですか。ありがとうございます。
今後も使えそうなコードなので参考にさせて頂きます。
いろいろありがとうございました。
1

スキルアップ/キャリアアップ(JOB@IT)