I'm using the following co开发者_StackOverflow社区de to highlight the selected row in a gridview. I want to remove this style when I click the cancel button.
<selectedrowstyle backcolor="LightCyan" forecolor="DarkBlue" font-bold="true"/>
I have used this code this.gvArticles.SelectedRow.Style.Clear();
to remove, but it is not working.
Can anyone pls help me out here.
Try this solution
clear selectedindex of gridview by setting it to -1.
this.gvArticles.selectedIndex = -1;
Or in the case of a gridview with a dataset as a datasource
protected void grdViewDetails_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
grdViewDetails.EditIndex = -1;
grdViewDetails.DataSource = YourDatasource; //a dataset in my case
//Bind data to the GridView control.
grdViewDetails.DataBind();
}
精彩评论