Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Datagrid

Datagrid

Scheduled Pinned Locked Moved C#
csshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abalfazl
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • A abalfazl

      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

      K Offline
      K Offline
      krario
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • K krario

        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.

        A Offline
        A Offline
        abalfazl
        wrote on last edited by
        #3

        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; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups