Silverlight / WPF - wpf datagrid custom paging and datagrid selection changed event
Asked By Mallikarjuna
07-Oct-10 01:48 AM
hi everyone ,i am new to wpf .I have implemented wpf Datagrid custom paging as given in this forum.It works perfectly but if i select a row in the datagrid to raise the datagrid_selectioncanged event handler ,first time selection changed event handler is executed but after if i click > command(at this time already one datagrid row is selected) in paging it will give the error like
"object reference is not set to object instance" in the following line of code
int id=int.parse(datagrid.selectedvalue.ToString());
But I get confused that ,if i click Next (>)command it wont go to Next Command instead it will come to selectionChanged event .Please tell me how to solve this problem.
Michael Detras replied to Mallikarjuna
Hi, the reason why the SelectedValue becomes null is because the ItemsSource of the DataGrid is changed when you click on the Next button. The currently selected item won't be found in the new ItemsSource. Either you check if the SelectedValue is null or set a default selection (like the first item) before you call int.parse().
Mallikarjuna replied to Michael Detras
wow, Thanks Michael Detras.Its Perfectly working.this is my first question to the forum.
Find control in datagrid silverlight Silverlight / WPF hi. . how to find a control in datagrid. . my datatexttemplate is below <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation = "Horizontal"> <TextBlock Height name}" Tag = "{Binding name}" VerticalAlignment = "Top" / > < / StackPanel> < / DataTemplate> < / sdk:DataGridTemplateColumn.CellTemplate> < / sdk:DataGridTemplateColumn> in my datagrid i have button and when i clicked the button then i need to get the achieve this. . need ur suggtesions. . regards gopal.s Try this coding in LoadingRow event of DataGrid. void datagrid_LoadingRow( object sender, DataGridRowEventArgs e) { ComboBox cbo = datagrid.Columns[ColumnIndex].GetCellContent(e.Row) as Combobox; / / HERE CHANGE THE Combobox control with your requirement
drag and drop row in silverlight datagrid Silverlight / WPF hi. . how to drag and drop row in silverlight datagrid? need ur suggestions with examples. . regards gopal.s Silverlight 2 Solution The first problem you will encounter in Silverlight 2 is determining how / when to initiate the drag operation. The most obvious route is
Computed Columns In WPF DataGrid Silverlight / WPF hie, I want to created computed columns like ms excel in wpf customized datagrid.Can anyone suggest some idea.for eg i have datagrid in following format: <DataGrid Name = "dgv" Grid.Row = "1" AutoGenerateColumns = "False"> <DataGrid.Columns> <DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid Name
how to acess textbox value from datagrid in wpf. . ? Silverlight / WPF hello frnds <WPF:DataGridTemplateColumn Header = "Result"> <WPF:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text = "{Binding Path = testresult}" Name = "tb" / > < / DataTemplate> < / WPF:DataGridTemplateColumn.CellTemplate> < / WPF:DataGridTemplateColumn> how to get textbox value, selected row of data grid, as shown in above
ANN: WPF DataGrid CTP .NET Framework Microsoft hat das oft vermisste WPF DataGrid Control als Open-Source CTP veröffentlicht: Blog WPF Toolkit - Preview Video DataGrid Preview & Control Investments in WPF 3.5 SP1 Codeplex WPF WPF Futures Roadmap - - Thomas Scheidegger - 'NETMaster' http: / / dnetmaster.net / C# - German Discussions Silverlight (1) DataGrid