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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Specified argument was out of the range of valid values. Parameter name: index.

Specified argument was out of the range of valid values. Parameter name: index.

Scheduled Pinned Locked Moved C#
helpdatabaseannouncementlearning
2 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.
  • H Offline
    H Offline
    haleemasher
    wrote on last edited by
    #1

    plz help i have a code for datagrid and i want to update it. it shows error "Specified argument was out of the range of valid values. Parameter name: index." plz check errors try { ErrorMessage.Text = ""; SqlCommand updCommand = new SqlCommand(); updCommand.Connection = cnx; updCommand.CommandText="UPDATE Student_Attendance Set Course_Id='" + ((TextBox)e.Item.Cells[3].Controls[0]).Text +"',Std_Id='"+((TextBox)e.Item.Cells[4].Controls[0]).Text +"',Class_Id='"+((TextBox)e.Item.Cells[5].Controls[0]).Text +"',Total_Lectures='"+((TextBox)e.Item.Cells[6].Controls[0]).Text +"',Attended_Lectures='"+((TextBox)e.Item.Cells[7].Controls[0]).Text +"'"; updCommand.CommandType=CommandType .Text; cnx.Open(); updCommand.ExecuteNonQuery(); da1.Fill(ds); Cache["studentdata"]=ds; DataGrid1.EditItemIndex= -1; bindGrid(); cnx.Close(); } catch (System.Exception ex) { ErrorMessage.Text=ex.Message; }

    S 1 Reply Last reply
    0
    • H haleemasher

      plz help i have a code for datagrid and i want to update it. it shows error "Specified argument was out of the range of valid values. Parameter name: index." plz check errors try { ErrorMessage.Text = ""; SqlCommand updCommand = new SqlCommand(); updCommand.Connection = cnx; updCommand.CommandText="UPDATE Student_Attendance Set Course_Id='" + ((TextBox)e.Item.Cells[3].Controls[0]).Text +"',Std_Id='"+((TextBox)e.Item.Cells[4].Controls[0]).Text +"',Class_Id='"+((TextBox)e.Item.Cells[5].Controls[0]).Text +"',Total_Lectures='"+((TextBox)e.Item.Cells[6].Controls[0]).Text +"',Attended_Lectures='"+((TextBox)e.Item.Cells[7].Controls[0]).Text +"'"; updCommand.CommandType=CommandType .Text; cnx.Open(); updCommand.ExecuteNonQuery(); da1.Fill(ds); Cache["studentdata"]=ds; DataGrid1.EditItemIndex= -1; bindGrid(); cnx.Close(); } catch (System.Exception ex) { ErrorMessage.Text=ex.Message; }

      S Offline
      S Offline
      Shyam K Pananghat
      wrote on last edited by
      #2

      check whether a column exist in the given index.. It says that the collection object doesn't have any items for your given index..

      Shyam.. My Blog dotnetscoups.blogspot.com

      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