Datagrid
-
Imagine DataGrid contains three columns of its DataSource And another columns of DataSource have been to fill with two TextBoxes . So I want to fill them when the new row in the grid is filling . The following code to do this operation : private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { try { int colNum; int rowNum; colNum = dataGrid1.CurrentCell.ColumnNumber; rowNum = dataGrid1.CurrentCell.RowNumber; //fill 2 columns of dataset int cod1,cod2; cod1=Int32 .Parse (textBox2.Text ); dataSet31 .factor .NewRow (); * dataSet31 .factor [rowNum ].proje_code=cod1; cod2=Int32 .Parse (textBox1.Text ); dataSet31 .factor [rowNum ].hazineh_code=cod2; } catch(Exception ex) { MessageBox .Show (ex.Message ); } } But in execution time when I click on forth row and it arrives to the marked line with star then this error message appears : there is no row in position 4 . I want to Insert the new information of DataGrid to my DataSet that has 5 columns . you khow that my DataGrid has 3columns of its DataSource(DataSet) . 2 TextBoxes fill the 2columns of DataSet . this 2 columns are the 2 field of primary key . in execution time when I fill a row of DataGrid this error appeares : . column ' proje_code' does not allow null Thanks
-
Imagine DataGrid contains three columns of its DataSource And another columns of DataSource have been to fill with two TextBoxes . So I want to fill them when the new row in the grid is filling . The following code to do this operation : private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { try { int colNum; int rowNum; colNum = dataGrid1.CurrentCell.ColumnNumber; rowNum = dataGrid1.CurrentCell.RowNumber; //fill 2 columns of dataset int cod1,cod2; cod1=Int32 .Parse (textBox2.Text ); dataSet31 .factor .NewRow (); * dataSet31 .factor [rowNum ].proje_code=cod1; cod2=Int32 .Parse (textBox1.Text ); dataSet31 .factor [rowNum ].hazineh_code=cod2; } catch(Exception ex) { MessageBox .Show (ex.Message ); } } But in execution time when I click on forth row and it arrives to the marked line with star then this error message appears : there is no row in position 4 . I want to Insert the new information of DataGrid to my DataSet that has 5 columns . you khow that my DataGrid has 3columns of its DataSource(DataSet) . 2 TextBoxes fill the 2columns of DataSet . this 2 columns are the 2 field of primary key . in execution time when I fill a row of DataGrid this error appeares : . column ' proje_code' does not allow null Thanks
-
Hi. Can you show us how you insert the two rows from TextBoxes to the DataSet. And what is this factor property of the DataSet.
Hello int colNum; int rowNum; colNum = dataGrid1.CurrentCell.ColumnNumber; rowNum = dataGrid1.CurrentCell.RowNumber; //fill 2 columns of dataset int cod1,cod2; cod1=Int32 .Parse (textBox2.Text ); dataSet31 .factor .NewRow (); * dataSet31 .factor [rowNum ].proje_code=cod1; cod2=Int32 .Parse (textBox1.Text ); dataSet31 .factor [rowNum ].hazineh_code=cod2; }