jvwiv Posted August 21, 2008 Report Share Posted August 21, 2008 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... JVW Quote Link to comment Share on other sites More sharing options...
StephenP Posted August 21, 2008 Report Share Posted August 21, 2008 Hi, Is the print button you are using Grid's print button the toolbar? Or is it a custom button you place in every item? Steve Quote Link to comment Share on other sites More sharing options...
jvwiv Posted August 22, 2008 Author Report Share Posted August 22, 2008 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... Thanks! jvwiv Quote Link to comment Share on other sites More sharing options...
StephenP Posted August 22, 2008 Report Share Posted August 22, 2008 Hey, 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. Highlight.zip Quote Link to comment Share on other sites More sharing options...
jvwiv Posted August 22, 2008 Author Report Share Posted August 22, 2008 Stephen, 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.