Jump to content
Software FX Community

Turning off the Grid Selection Toggle


Recommended Posts

Hi Guys,

I have a grid that contains a pushbutton that executes code.  Due to the type of code executed, Response.redirect, I can't have a call back and as such, the button is not a custom command.  My users called complaining about an error they were getting when the run the application.  Essentially, the error is that the grid1.selecteditems.count = 0 even though they selected the item, then clicked on the print button.  What is happening, is that when the print button is pressed, the line is being deselected then the event is processing thereby causing grid1.selecteditems.count to be 0 instead of 1.  How can I change the behaviour of the button or the grid so you cant deselect a line by clicking on it again?  I only want you to be able to deselect a line when you click on the next line but don't want to force my users to have to select a line prior to clicking on the print button. 

Your help is appreciated...


Link to comment
Share on other sites

The button is an ASP.net button placed on the row.  When clicking it, the selected row becomes deselected, and versa visa if it wasn't selected. 

In researching if all grids had the issue I found that some of my grids didn't exhibit this behaviour.  the common issue there was a side bar.  If a grid has a side bar the selection doesn't get toggled.  So to resolve my issue I simply added a sidebar to the grid.

But it does bring up the issue of how I can turn on/off multi row selection...



Link to comment
Share on other sites


Now I got it.  I found a way for you to prevent the item from deselecting when the button is clicked.  What you need to do to fix it now is set a property (OnClientClick) to your button.

<asp:Button runat="server" OnClientClick="(new Sys.UI.DomEvent(event)).stopPropagation();" ID="btn1" onclick="btn1_Click" />

That willl prevent the Click event from bubbling up to the cell, at which point will cause the deselection of the item.

The upcoming service pack includes a new property, Grid.Selection.DeselectSingleItemOnClick, which will prevent an item from being deselected on click when its already selected.  That will do exactly what you want without having to modify the button.

Have you used our CommandButton control?  It does what the regular button does but uses a callback instead of a postback.


Link to comment
Share on other sites


I'll give the stopPropagation a try. 

I couldn't use the CustomCommand command button due to the fact that I'm doing a responseredirect, which I understand will be resolved in the next service pack as well.

By the By, when will that be coming out and where can I get a list of the enhancements that will be included?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...