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:
|
"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 paxPosted Oct 21, 2009, 12:47 AM
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());
Amit ChoudharyPosted Oct 21, 2009, 5:30 AM
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
Nilanka DharmadasaPosted Oct 21, 2009, 12:45 AM
datagrid.DataSource = ds.Tables[0];
Even for the checkbox column you can directly set the values.
If you have any problem pls ask.