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. .NET (Core and Framework)
  4. datagridview using c#

datagridview using c#

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpsharepointhelp
1 Posts 1 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.
  • K Offline
    K Offline
    kulandaivel_mca2007
    wrote on last edited by
    #1

    i bind one table in my datagridview i have 4 check box in my datagridview... one for present... second one for absent... third one for morning present... fourth one for evening present... if i check only one check box i get the following error... // ERROR // Object reference not set to an instance of an object. bcz i assigned check box value to one string variable... string value11 =”aa” , value22 =”aa” , value33 =”aa” , value44 =”aa” ; con27.Open(); int rows = dataGridView1.Rows.Count; rows = rows - 1; for (int i = 0; i < rows; i++) { SqlCommand cmd27 = new SqlCommand("sp_update_att_lkg", con27); cmd27.CommandType = CommandType.StoredProcedure; value11 = dataGridView1.Rows[i].Cells[0].Value.ToString(); value22 = dataGridView1.Rows[i].Cells[1].Value.ToString(); value33 = dataGridView1.Rows[i].Cells[2].Value.ToString(); value44 = dataGridView1.Rows[i].Cells[3].Value.ToString(); string value10 = dataGridView1.Rows[i].Cells[4].Value.ToString();// S_ID string value6 = dataGridView1.Rows[i].Cells[5].Value.ToString();// name string value7 = dataGridView1.Rows[i].Cells[6].Value.ToString();// class string value8 = dataGridView1.Rows[i].Cells[7].Value.ToString();//section string value9 = dataGridView1.Rows[i].Cells[8].Value.ToString();// scode string value5 = dataGridView1.Rows[i].Cells[9].Value.ToString();// uid string dt1 = dateTimePicker1.Text; DateTime DT = DateTime.Parse(dt1); // ATTENDANCE if (value11 == "True") { value11 = "present"; } else { value11 = "absent"; } cmd27.Parameters.Add(new SqlParameter("@puid", SqlDbType.Int)); cmd27.Parameters["@puid"].Value = value5; cmd27.Parameters.Add(new SqlParameter("@pname", SqlDbType.VarChar)); cmd27.Parameters["@pname"].Value = value6; cmd27.Parameters.Add(new SqlParameter("@pclass", SqlDbType.VarChar)); cmd27.Parameters["@pclass"].Value = value7; cmd27.Parameters.Add(new SqlParameter("@psection", SqlDbType.VarChar )); cmd27.Parameters["@psection"].Value = value8; cmd27.Parameters.Add(new SqlParameter("@pcode", SqlDbType.VarChar)); cmd27.Parameters["@pcode"].Value = value9; cmd27.Parameters.Add(new SqlParameter("@pattend",SqlDbType.DateTime)); cmd27.Parameters["@pattendance"].Value = DT; cmd27.Parameters.Add(new SqlParameter("@pstatus", SqlDbType.VarChar)); cmd27.Parameters["@pstatus"].Value = value11; cmd27.Parameters.Add(new SqlParameter("@ps_id", SqlDbType.VarChar)); cmd27.Parameters["@ps_id"].Value = value10; cmd27.ExecuteNonQuery(); } expecting suggestion

    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