Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear selection of a gridview row?

Tags:

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?

like image 672
Different111222 Avatar asked Apr 29 '12 21:04

Different111222


People also ask

How do you clear a selection in C#?

ClearSelection() Clears the current selection by unselecting all selected cells.

How to delete selected row in GridView using c#?

The User selects the row from the checkbox that he want to delete and on a button click it is deleted from the GridView and from the database too. Open Visual Studio 2010 and create an Empty Website, provide a suitable name (Gridview_demo). In Solution Explorer you get your empty website.


2 Answers

Try this:

Gridview has a property called SelectedIndex.   If you want to unselect any rows then set this property to -1.   
like image 176
coder Avatar answered Oct 10 '22 03:10

coder


Thank you for your question Different111222; This question helped me.

gvInfo.SelectedIndex = -1;  

Hope this helps!

like image 33
Catto Avatar answered Oct 10 '22 02:10

Catto