LinkButton及RowCommand事件中获取Gridview中行索引并此行变色

来源:互联网 发布:知合控股的工作节奏 编辑:程序博客网 时间:2024/05/01 03:30

LinkButton及RowCommand事件中获取Gridview中行索引并此行变色

LinkButton myL = (LinkButton)sender;
int Index = ((GridViewRow)(myL.NamingContainer)).RowIndex;//获得行号
gvManageSuggestion.Rows[Index].RowState = DataControlRowState.Selected;//行的状态
gvManageSuggestion.SelectedRowStyle.BackColor = Color.Gray;//行背景色

 //gvManageSuggestion.Rows[Index].Attributes.Add("style ", "BACKGROUND-COLOR:#dddddd ");//行背景色

 

RowCommand事件中获取行号

GridViewRow row=((LinkButton )e.CommandSource).Parent.Parent as GridViewRow;

原创粉丝点击