C
C#7mo ago
RXPHXEL

Data Grid View is not showing data.

Hi, I am writing a library project with N Layered Architecture, like I mentioned in the thread, DGV it is not showing any data but adding it and sending it to the SQL, since it is not showing any data I cannot check if it updates or deletes, could you please help me how can I solve this issue? I google'd it but cannot find any solution.
No description
No description
No description
5 Replies
Jimmacle
Jimmacle7mo ago
you didn't share any code that loads data from your database
exixt
exixt7mo ago
code please, xoxo
RXPHXEL
RXPHXELOP7mo ago
I am sorry guys I added this while I was half sleepy those are the related codes
No description
No description
No description
leowest
leowest7mo ago
for a start please do not make your fields publid, in the above example there is absolute no need to even have fields you ould just write
public class BookInformation
{
public int Id {get;set;}
public string BookName {get;set;}
public string AuthorName {get;set;}
public string BorrowerName {get;set;}
public DateTime BorrowDate {get;set;}
}
public class BookInformation
{
public int Id {get;set;}
public string BookName {get;set;}
public string AuthorName {get;set;}
public string BorrowerName {get;set;}
public DateTime BorrowDate {get;set;}
}
If for whatever reason your teaher wants you to use the backing fields, then:
public class BookInformation
{
private int id;
private string bookName;
private string authorName;
private string borrowerName;
private DateTime borrowDate;

public int Id { get => id; set => id = value; }
public string BookName { get => bookName; set => bookName = value; }
public string AuthorName { get => authorName; set => authorName = value; }
public string BorrowerName { get => borrowerName; set => borrowerName = value; }
public DateTime BorrowDate { get => borrowDate; set => borrowDate = value; }
}
public class BookInformation
{
private int id;
private string bookName;
private string authorName;
private string borrowerName;
private DateTime borrowDate;

public int Id { get => id; set => id = value; }
public string BookName { get => bookName; set => bookName = value; }
public string AuthorName { get => authorName; set => authorName = value; }
public string BorrowerName { get => borrowerName; set => borrowerName = value; }
public DateTime BorrowDate { get => borrowDate; set => borrowDate = value; }
}
aside from that you're binding a empty new List<BookInformation> to your datagrid hence why its empty
private void B_List_Click(object sender, EventArgs e)
{
DGV_BookList.DataSource = ???.LogicLayerListBookInformation();
}
private void B_List_Click(object sender, EventArgs e)
{
DGV_BookList.DataSource = ???.LogicLayerListBookInformation();
}
I dont know how or if ur creating an instance of LogicBookInformation as u dont show more code. so I assume u have a singleton for that and for your DAL
RXPHXEL
RXPHXELOP7mo ago
Man thank you so much it worked
Want results from more Discord servers?
Add your server