I want to display some data in the gridView1 from a list but it won't show the data just the header row. I created a datasource object Transakcija and selected it as a data source for the gridControl but it just doesn't display the actual data.
private void Form1_Load(object sender, EventArgs e)
{
List<Transakcija> list1 = new List<Transakcija>();
list1.Add(new Transakcija
{
TrnType = "1",
IzvodBroj = "2",
NovoStanje = "3",
PrethodnoStanje = "4",
FitID = "5",
TrnUID = "6",
Benefit = "7",
NazivPrimaoca = "8",
Grad = "9",
Racun = "10",
BankID = "11",
Banka = "12",
Datum = "13",
Iznos = "14",
SvrhaPlacanja = "15",
Sifra = "16",
Valuta = "17",
PayeeRefNumber = "18",
TrnPlace = "19",
DtUser = "20",
DtAvail = "21",
RefNumber = "22",
RefModel = "23",
PayeeRefModel = "24",
Urgency = "25",
Naknada = "26",
StatusCode = "27",
StatusTimePosted = "28",
RacunBanke = "29"
});
gridControl1.DataSource = new System.ComponentModel.BindingList<Transakcija>(list1);
gridControl1.Refresh();
}
I tried looking at the properties of the grid control but I didn't find why it doesn't display it.
After some investigation I have a potential solution for you (its a best guess as you haven't provided the definition of the class
Transakcijaor shown how the columns are defined or added to the GridControl/GridView).There are also other considerations such as setting the FieldName of the GridColumn.
I found that it depends on how your class
Transakcijais defined.If the members
TrnType,IzvodBroj,NovoStanje, etc are defined as Fields then it won't work. They need to be defined as Properties.This does not work
This does work: