[ASP.NET][Event] Control event catch DATAROW Index in the GridView

摘要:[ASP.NET]Control event catch DATAROW Index in the DataGridView

 

    protected void Button1_Click(object sender, EventArgs e)
    {
        //Object轉換控制項型別
        Button btn = (Button)sender;
        //尋找上層控制項(父控制項)
        //GridViewRow gvr = (GridViewRow)btn.Parent.Parent;
        DataCell dc = (DataCell)btn.Parent;
        GridViewRow gvr = (GridViewRow)dc.Parent;
        int intRowIndex = gvr.RowIndex;
        Response.Write("<script>window.open('SampleOrder(zh-TW).aspx?RowIndex=" + intRowIndex.ToString()+ "');</script>");
      }