Search code examples
c#asp.net

How do I clear selection of a gridview row?


I'm using C# ASP.NET VS2010.

I have a GridView including a select command button.

This select button points to an action in the code behind C# page activated upon selection.

After performing all required action I would like to clear the selection.

For example: in case the ID="gvInfo" I would like to use something like gvInfo.Deselect();

How do I do that?


Solution

  • As explained in https://social.msdn.microsoft.com/Forums/en-US/8a4937d1-531a-49d7-9392-bb76cb9bfcb7/how-to-clear-selectedrow-in-a-gridview?forum=aspwebformsdata

    Gridview has a property called SelectedIndex. If you want to unselect any rows then set this property to -1.