problem in binding data to gridview
The below is my code for binding data to gridview.
This method for creating datagridview column
Collapse | Copy Code
public void designgrid()
{
DataGridViewColumn firstcolumn=dataGridView1.Columns[1];
DataGridViewCell cell=new DataGridViewTextBoxCell();
firstcolumn.CellTemplate=cell;
firstcolumn.HeaderText = "AdmissionNumber";
firstcolumn.Width = 50;
DataGridViewColumn secondcolumn = dataGridView1.Columns[2];
DataGridViewCell cell1 = new DataGridViewTextBoxCell();
secondcolumn.CellTemplate = cell1;
secondcolumn.HeaderText = "StudentName";
secondcolumn.Width = 80;
DataGridViewColumn Thirdcolumn = dataGridView1.Columns[3];
DataGridViewCell cell2 = new DataGridViewTextBoxCell();
Thirdcolumn.CellTemplate = cell1;
Thirdcolumn.HeaderText = "StanderedName";
Thirdcolumn.Width = 80;
DataGridViewColumn forthcolumn = dataGridView1.Columns[4];
DataGridViewCell cell3 = new DataGridViewTextBoxCell();
forthcolumn.CellTemplate = cell3;
forthcolumn.HeaderText = "RegisterNumber";
forthcolumn.Width = 50;
DataGridViewColumn fifthcolumn = dataGridView1.Columns[5];
fifthcolumn = new DataGridViewComboBoxColumn();
fifthcolumn.HeaderText = "SortNo";
fifthcolumn.Width = 50;
}
This code for binding data to gridview
Collapse | Copy Code
DataTable studentbind = ibl4.studentbindforfemale(sdt);
int rowcount = studentbind.Rows.Count;
List no = ibl4.setnoofint(rowcount);
int registerno = ibl4.getregiter(sdt);
designgrid();
for(int i=0;i