asp.net gridview ItemTemplate 获得 一行 数据

大多数情况是给按钮CommandName,然后在RowCommand事件中处理



    
        Up  
    


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "up")
    {
        int index = ((GridViewRow)((Button)e.CommandSource).NamingContainer).RowIndex;
        //如果是TemplateField
        string str = ((Label)(GridView1.Rows[index].FindControl("控件名"))).Text;
        //如果是BoundField
        string str = (GridView1.Rows[index].Cells[单元格索引].Text;
    }
}



http://bbs.csdn.net/topics/230014259

你可能感兴趣的:(asp.net)