[問題] ASP gridview按鈕 開啟當行的詳細子畫面

看板Web_Design作者 (小呆熊)時間7年前 (2018/03/22 11:37), 編輯推噓1(100)
留言1則, 1人參與, 7年前最新討論串1/1
以下是我前端的程式碼 <asp:GridView ID="GridView1" runat="server" Width="970px" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" EnableEventValidation="false" Visible="False" EmptyDataText="查無資料,請用新增按鈕新增" onselectedindexchanged="GridView1_SelectedIndexChanged" > <Columns> <asp:BoundField DataField="序號" HeaderText="序號" SortExpression="序號" /> <asp:BoundField DataField="病歷號" HeaderText="病歷號" SortExpression="病歷號" /> <asp:BoundField DataField="病患名稱" HeaderText="病患名稱" SortExpression="病患名稱" /> <asp:BoundField DataField="建檔日期" HeaderText="建檔日期" SortExpression="建檔日期" /> <asp:BoundField DataField="主治醫師" HeaderText="主治醫師" SortExpression="主治醫師" /> <asp:HyperLinkField NavigateUrl="Cancerplan-edit.aspx" Text="修改 " /> <asp:ButtonField ButtonType="Button" CommandName="mys" Text="修改 " /> </Columns> </asp:GridView> 以下是我 ButtonField的內容 想知道是否有抓取到該行序號 然後要如何修正能跳到子畫面 把對應詳細內容呼叫出來 protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e) { Response.Write("e.CommandName = " + e.CommandName+"</br>"); if (e.CommandName == "mys") { int i = Convert.ToInt32(e.CommandArgument); Response.Write("e.CommandArgument=" + i); Response.Write("第" + i + "列" + "第1格是---" + GridView1.Rows[i].Cells[1].Text); Response.Write( "主key是 ="+GridView1.DataKeys[i].Value.ToString()); } } protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e) { Response.Write("e.CommandName = " + e.CommandName+"</br>"); if (e.CommandName == "mys") { int i = Convert.ToInt32(e.CommandArgument); Response.Write("e.CommandArgument=" + i); Response.Write("第" + i + "列" + "第1格是---" + GridView1.Rows[i].Cells[1].Text); Response.Write( "主key是 ="+GridView1.DataKeys[i].Value.ToString()); } } 我知道子畫面如何讀到資料並顯示 但跳頁部分 一直無法成功 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.126.7.201 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1521689820.A.7C3.html

03/26 20:36, 7年前 , 1F
跳頁?
03/26 20:36, 1F
文章代碼(AID): #1QioJSV3 (Web_Design)
文章代碼(AID): #1QioJSV3 (Web_Design)