开发者

How to remove the selecterow style in a gridview on cancel button - asp.net

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();
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜