How to get the selected rows in ASPxGridView? - asp.net

I have a grid with ASPxCheckBox in Data Item Template. How to get KeyFieldValue of all rows whose checkbox is checked. I am trying to do this using client-side code and do it for whole grid not on visible index. Is it possible?
Note: I cannot use simple row selection command column as I am using it for some other purpose.

if you dontuse client-side code, you should use detailrow in aspxgridview. And you must use beforeperformdataselect event. if you really need checkbox, you can add checkbox a new field in asapxgridview.

Related

Using bindings with BrazosUI buttons

I'm used to using boolean bindings with IBM buttons to track if a button is clicked. The button in Brazos UI can be bound to any variable type but doesn't make automatic updates to booleans. How do I use bindings with Brazos UI buttons to track which was last-clicked?
The binding of a button is really only useful in tables. The acceptance of ANY variable type for the binding of a button stems from the use of determining the index of a selected row or obtaining the entire row object:
If you bind and integer to the button in a table, the binding will update with the index of the row when the button is clicked.
If you bind a variable of the same (singular) type as the table's binding, then clicking the button will update the binding with that row's data.
Both of those are handy interactions with the table control but don't work for tracking which button is clicked when used elsewhere on a coach. For that, you want to utilize the 'Button Control ID' configuration option. The most direct method is to bind the same string variable to all of the buttons you need to track. When clicked, a button will update that shared variable to match its own control ID. You can then use that unique ID in various scripting checks to take button-specific actions.
See the BP3 Help Center article for greater detail about this, including some examples: https://support.bp-3.com/hc/en-us/articles/217985767-Using-Button-Binding-with-Brazos-UI

Devexpress Gridcontrol Multiselect without using indicator column

Is there any way to allow the user to do a multiple row selection just by clicking and dragging along cells within the actual grid? I.e. Without using the indicator column?
You can do that by cell using just properties by setting the following properties located in Gridview.Options
Multiselect = True
MultiSelectMode = CellSelect
UseIndicatorForSelection = False
If you need to do it by entire rows, you are stuck writing that functionality yourself using GridView.CalcHitInfo and various events.
To achieve this behavior, you need to handle the MouseDown and
MouseMove events and select rows programmatically. You also need to
enable the multi-selection feature and switch the multi-selection
mode to "CellSelect" to be able to select individual cells.
download the attached sample from this link and customize it to implement your functionality...
MultiSelect Rows & Cells simultaneously
check the following thread, which using indicator but you can customize it hiding indicator and setting select option to cellselect etc...
"mulitiselect without CTRL key" on Devexpress..
search result that help you implement that you are looking for...

Reassign Checked rows from one GridView to another

I have a gridview that has a checkbox (inside TemplateField). I would like to grab all the selected rows and reassign them to a new gridview. Any ideas on how I can go about doing this?
Thanking you in advance.
If I understand your question, the easisest way to do it is to wrap the second grid in a separate grid. Assuming you have named the checkboxses the same id for your second grid, you can use jquery plugin to detect selection of the first grid's check boxes, loop through the results and set check boxes of your second grid inside that other div to "checked" since the names of the chck boxes match.
Something like that:
$(document).ready(function () {
$('#BaseDiv > input[name=checkboxlist]:checked').each(function() {
//TODO: Retrieve the checkboxes from the second div using the combination of second div id and search for it's children check boxes.
});
});
just fetch all the checked rows from the first gridview and add them into a datatable. Now assign this datatable to another gridview as datasource and bind it.

Adding a new row in between rows in a grid view

I have an ASP .net grid view. It has some template columns like a command button, a text box, and a dropdown control. When I click the command button, a new row needs to be inserted below the current row (from where I hit the command button).
If I have rows 1 and 2 and I hit the command button in row1 a new row needs to be inserted between rows 1 and 2
Now in the new row I should be able to select values from dropdown and enter some value in a text box and finally hit my save button. (Which should work fine as I am expecting)
The grid view is bound to some data source say for instance a datatable for now.
Oneway that I could think about is when Command button is clicked, I can add a new row to the datatable in my server side code and rebind the grid. But I am not sure that, from a UI perspective how I can make sure that the new row goes exactly below the row from where I hit the command button.
Any thoughts or comments?
I think a much easier approach will be if you try to add the row in your data source and then bind to the GridView again. This is easy if you have DataSet or a custom entity collection. Since, you are using DataTable this will also work. Handle the click event and find the row that the user clicked. Go back to the dataTable and add an empty row there. This will make sure that the controls inside the GridView are persisted and you don't have to worry about adding DropDown controls etc.
You have to sort the datasource by an virtual index saved in an invisible column. On first databound(perhaps you take a DataView because of ots sorting capability) it will set to the original rowindex. After first hit of the save button you get the datatable again from database and add the additional row with an index after the "selected" row. Then you bind the GridView again with the sorted DataView.
I think you need another invisible column to detect the "temporary" row. If you dont need to edit the "normal" rows then you can use edititemtemplate for this. Otherwise you can make the dropdown and textbox visible and the other controls invisible in GridView.OnRoawDataBound.
There is a code sample that is used for adding a new row in between rows in a grid view.

how to make an checkboxlist select only one item selected

i am using an checkboslist binding to a datatable.
but here i need to make user select only one item selected from checkbox list
is there way we can aachive this
either JQuery, javascript, c#
thank you
If the user is only allowed to select one item from a list, you should use radio buttons instead of checkboxes.
UPDATE:
If you have to use checkboxes then you can use the following code:
$("#myform :checkbox").click(function(){
$("#myform input:checked").attr("checked","");
$(this).attr("checked","checked");
});

Resources