ASPxGridView GetSelectedFieldValues not working

a0hmcqle

New Member
I want to select a row and do something with it's Id column, however it isn't working and I'm running into the error mentioned at the end.Heres what I got -The ASPxGridView snippet -\[code\]<dx:ASPxGridView ID="ASPxGridView1" runat="server" Font-Names="Arial" Font-Size="Small" Width="100%" ClientInstanceName="grid" oncustomcallback="grid_CustomCallback" onbeforegetcallbackresult="ASPxGridView1_BeforeGetCallbackResult" EnableCallBacks="False" EnableRowsCache="False" KeyFieldName="ID">... Columns here ...<ClientSideEvents ContextMenu="OnContextMenu" SelectionChanged="OnSelectionChanged" /> </dx:ASPxGridView>\[/code\]Note: The grid gets populated via a DataTableDataTable code -\[code\]protected DataTable GetHeadlineData(SqlDataReader rdr){ DataTable headlineTable = new DataTable(); headlineTable.Load(rdr) headlineTable.PrimaryKey = new DataColumn[] { headlineTable.Columns["ID"] }; return headlineTable;}\[/code\]PageLoad code -\[code\]DataTable dt= new DataTable(); dt= FillGrid(); //this function internally calls the above GetHeadlineData functionSession["headTable"] = dt;ASPxGridView1.DataSource = Session["headTable"];ASPxGridView1.KeyFieldName = "ID";ASPxGridView1.DataBind();\[/code\]SelectionChanged functions -\[code\] function OnSelectionChanged(s, e) { grid.GetSelectedFieldValues("ID", OnGetSelectedFieldValues); } function OnGetSelectedFieldValues(result) { for (var i = 0; i < result.length; i++) for (var j = 0; j < result.length; j++) { document.getElementById('selectedRowDiv').innerHTML = result; } } \[/code\]Error I'm getting -\[code\]A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case.\[/code\]
 
Top