I haev created a Data Grid view control at design and add three columns at design time one includes a check box.
Then at the buton clicck event:
C# |
"DBConn" object of class DBConnection that has the method GetAllReocrds() that returns a Dataset that has a three columned table.
What i was trying to do is to load each cell value of the retuned table to the cells of the dgvMulti... unforntuately "dgvMulti.Rows[i].Cells[0]" thorws an error. the cells werre created. How do i fix this and add data to the dgvMulti?
TY

naura paxRank #2,843 · 502 reputationPosted Oct 20, 2009, 8:47 PM EDT
why don't you try this
error that you are getting is because no cells have been added in the datagridview.
There is an alternate for above -: you can also write a code for adding a row in the datagridview
foreach(DataRow dr in ds.Tables[0].Rows[0)
dgvMulti.Rows.Add(dr["CheckBoxColumn"].ToString(),dr["Col1"].ToString(),dr["Col2"].ToString());
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Oct 20, 2009, 8:45 PM EDT
datagrid.DataSource = ds.Tables[0];
Even for the checkbox column you can directly set the values.
If you have any problem pls ask.
Amit ChoudharyRank #145 · 15.8K reputationPosted Oct 21, 2009, 1:30 AM EDT
you can also design the item template for that and only one check box you add in item template and you will get it in all your Grid rows