GridView获得操作列的值

来源:互联网 发布:明解c语言中级篇 pdf 编辑:程序博客网 时间:2024/05/21 19:33

第一步:

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Button btn = (Button)e.Row.Cells[3].Controls[0];
            btn.CommandArgument = e.Row.RowIndex.ToString();
        }
    }

第二步:

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int rowIndex = Convert.ToInt32(e.CommandArgument);
        if (e.CommandName == "query")
        {
            string startTime =((TextBox)this.GridView1.Rows[rowIndex].Cells[1].FindControl("ConvertDate1").FindControl("txbTime")).Text;

            Response.Write(startTime);
        }
    } 

原创粉丝点击