0

My datagridview is in RowHeaderSelect mode. So clicking on the RowHeader selects the whole row.

However, at any point, when i use context menu shortcuts or shortcut keys from the keyboard, i need to check if a whole row is currently selected, or just a single cell, and perform actions accordingly. How do I check this?

Vivek
  • 255
  • 1
  • 5
  • 16
  • 1
    How are you processing the row, won't the `CurrentRow` help you in executing your logic ? Or i guess you are better off setting the `SelectionMode` to `FullRowSelect` – V4Vendetta Mar 26 '13 at 05:56

2 Answers2

0

you can check with e.CommandName property.

Check foolowing patch of code>>

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        SXEngine.Classx USER = (SXEngine.Classx)Session["APPOBJ"];        

        if (e.CommandName == "Select")
        {
            USER.bRowSelect = true;         
        }
        else
        {
            USER.bRowSelect = false ;
        }
    }

Study this link to get more info regarding different properties of gridview>>

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanging.aspx

Freelancer
  • 9,008
  • 7
  • 42
  • 81
0

Use CommandName method of RowCommand event's argument e. like

if(e.CommandName=="Select")   
{
   //code
}
Mogli
  • 1,972
  • 11
  • 34
  • 67