I have a Datagridview, and a field from the database. I want save this field to row tag in gridview, but after saving to the tag with a Foreach loop, in another function I see it returns null value. How do I save this field? Thank you
private void UC_DKHoc_Load(object sender, EventArgs e)
{
var dsLop = LopDangKyServices.LayDanhSachLopDangKy();
var DatasourceGV = from lop in dsLop
select new
{
lop.MaLopDangKy,
lop.TenLopDangKy,
lop.CLB1.TenCLB,
lop.NamHoc,
lop.HocPhi,
lop.LichHoc
};
advancedDataGridView.DataSource = DatasourceGV.ToList(); // Display to gridview
int i = 0;
foreach (DataGridViewRow row in advancedDataGridView.Rows)
{
row.Tag = dsLop[i++].CLB; //save complete
}
advancedDataGridView.DisableFilter(STT);
}
In The function I see null values.
private void simpleButton1_Click(object sender, EventArgs e)
{
MessageBox.Show(advancedDataGridView.Rows[1].Tag.ToString()); //Null value
}
select newand define columns of the datagridview that are shown. - user12031933row.Cells[0].Value = dsLop[i++].CLB;In above statement 0 will the cell number of the Tag in row. - Sibgath