I want to get the data every column from a datagrid connected to an Entity Framework database. I want to cast them to their respective Textboxes but I can't seemingly draw the data from the datagrid.
Here's the code I am using at first (saw it here on SO):
private void DataGridCamiao_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid DataGridCamiao = sender as DataGrid;
DataRowView row = (DataRowView)DataGridCamiao.SelectedItems[0];
TextBoxMarca.Text = row["Marca"].ToString();
}
Though after running it gives me an error:
System.InvalidCastException: Cannot associate (my custom type) to DataRowView
I've read about it and I've changed it to my custom type, to which it says it can't be indexed and does not run, which basically left me stumped as I tried other methods. I'd like some insight on what I'm doing wrong here, maybe different ways to achieve the same goal and I forwardly thank anyone trying to help me out.