_SelectionChanged event doesn't recognize data with null fields - asp.net

I'm having some problems with the _SelectionChanged event on an ASPX grid view using devexpress v9.3.
The ASPX Gridview that is on the page doesn't recognize rows where some cells have no value. I can select rows where all of the cells have been populated and the keyFieldName is returned, however if some of the rows have no data it wont return anything.
I know each row has been assigned data for the KeyFieldName as I have outputted this to the grid.
Can anyone help me please x

Found the issue. The grid view in my business logic was incorrect and I had applied the wrong variable to the keyfieldname.. Doh!

Related

ASPXGridView (devexpress) Hyperlink column sorting

I have a DevExpress ASPx GridView control and am trying to implement sorting for the grid columns.
The gridView contains has integer values in one column, text in the rest. I also have a column which contains hyperlinks and is added through the code behind during run time.
I am using the Aspxgrid_CustomColumnSort event for sorting the grid.
I can achieve the sorting for the column which contains the integer values and texts successfully, however the same code is not working for the column with hyperlinks.
When I click on the column header the hyperlinks sorts in ascending order,
but when I click the header the second time the grid isnt getting sorted in the descending order, the hyperlinks are sorted in randomn order ( neither ascending nor descending)
And, further clicks on the header do not do anything.
Any advice/suggestion will be greatly appreciated.
Maybe this link will help: http://www.devexpress.com/Support/Center/p/B145444.aspx. In this page, someone had reported an issue using the GridViewDataHyperLinkColumn.

Edit first column of GridView

I've got very dynamic GridView and I need to allow to user to edit first column of it. After he edit first column of grid it must be updated on DataBase.
Is there any ways to handle it ?
My only idea is to put some changeable element to first cell of each Row so it must be able to set / get my values for each row but can't find yet any examples of it ...
Additional info :
GridView takes data from Object data source and all columns are dynamic (yes, maybe except first, but I add it in dynamic way) and load complete DataTable... \
Currently Using jQuery+Ajax methode on dynamic button but can't disable button's PostBack so with a PostBack it just disappears and dont make the event it must to make...
Since you have dymanic columns, for each column, specify the read-only property (If a column is read-only, it may only be looked at, and not edited when in the GridView's Edit-Mode).
So, the first column of would be readonly="false" (or omit it entirely) and the other columns read-only="true".

How to get proper row index values of grid view after sorting

I have an asp.net application in which I am using a grid view. Paging and sorting are applied to the grid view. One action what I am doing is on click of any grid view row, am getting the column values of the selected row and redirecting to the other page.
The problem is after the grid view is sorted, if I click on any of the row in ayy page (paging index), am getting only first page values even though the visible row is different.
I am getting the row values in gridview_rowcreated() method and putting in some variable. In sorting scenario, before sorting is done, the gridview_rowcreated() method is called but not after the sorting is done.
In case you still need an answer to this...
You should be using the gridview's SelectedIndexChanging event with something like the following:
gridView.Rows.Item(intNewIndex).Cells(# of column, zero-based).Text
This will give each cell's current value, you'll just have to loop through each cell and assign each cell's value to desired variable(s).
Hope this helps!!!

How to Display a DataGrid with Insert Mode without any pre-filled data?

How to display the datagrid in insert mode without any data in it.
The GridView is empty and contains only one header.
I want to insert the data in the GridView when the application is running.
What you could do is using an empty Binding Source to a List which would enable you to add new Rows.
Check out some samples of how to use the Binding Source here
Please have a look at these 2 examples:
Insert rows with a GridView
Adding Insert Capabilities to the GridView
I don't think the datagrid will be rendered if its data source is empty. To work around this problem you can give it a data source with only one item that is regarded as empty (for example a data table with one row where all columns have empty values). You can then check for this special case in your program logic.

Get Changed Rows of GridView ASP.Net

How Can I find all the rows that has been changed in gridview. I can not use Ajax in any form
First get the contents of your grid before it was changed (such as caching the results of the original gridview datasource binding). Then go through the dataset/datatable/however you want to store it, and compare the contents with the current rows of the gridview.
There's no real efficient way to do this, no method like GridView.GetAllChangedRows(). So, what you might do instead is keep a behind the scenes List that you add to each time a row is modified (use the RowUpdated method), then clear this list when needed.
It depends upon how many columns you want to edit in a row.
If you have only one editable column in a row then you can associate a javascript method with that control which you want to modify and in that method you can get a rowid which you can save in another hidden field and in server side you can get all rows whose ids are stored in hidden field.
If you have whole row editable in that case the best approach I think you should save the original data source somewhere and also set a javascript method with rowclick event to get rowid which user selects. Then when user clicks on submit button get all rows whose row ids are stored in hidden field then compare those with same rowid in datasource. This is the best approach from my point of you.
Let me give you an example, suppose there are 1000 rows in a grid and user clicks on only 180 rows. In that case we will compare only 180 rows and wont compare rest of the rows.
Please let me know if somebody has better idea then this.

Resources