开发者

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

开发者 https://www.devze.com 2023-02-19 10:44 出处:网络
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.

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

精彩评论

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