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. Web Development
  3. ASP.NET
  4. Input string was not in a correct format. in Rowcommand of a GridView

Input string was not in a correct format. in Rowcommand of a GridView

Scheduled Pinned Locked Moved ASP.NET
databasehelp
4 Posts 3 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.
  • N Offline
    N Offline
    NET India
    wrote on last edited by
    #1

    Hello Friends, I've a GridView in which i've taken a LinkButton as TemplateField and that's CommandName is "Play". And now i want to print the index value of the row accordingly the Play button of the GridView's row is clicked. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Play") { int index = Convert.ToInt32(e.CommandArgument); Response.Write(index); } } And i'm getting an error Input string was not in a correct format"

    C S 2 Replies Last reply
    0
    • N NET India

      Hello Friends, I've a GridView in which i've taken a LinkButton as TemplateField and that's CommandName is "Play". And now i want to print the index value of the row accordingly the Play button of the GridView's row is clicked. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Play") { int index = Convert.ToInt32(e.CommandArgument); Response.Write(index); } } And i'm getting an error Input string was not in a correct format"

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      .NET- India wrote:

      int index = Convert.ToInt32(e.CommandArgument); Response.Write(index);

      1 - why do you need to convert this to an int to write it ? 2 - your error probably means the input was not an int, which is why you should never use Convert.ToInt32 ( use int.TryParse )

      Christian Graus Driven to the arms of OSX by Vista.

      N 1 Reply Last reply
      0
      • C Christian Graus

        .NET- India wrote:

        int index = Convert.ToInt32(e.CommandArgument); Response.Write(index);

        1 - why do you need to convert this to an int to write it ? 2 - your error probably means the input was not an int, which is why you should never use Convert.ToInt32 ( use int.TryParse )

        Christian Graus Driven to the arms of OSX by Vista.

        N Offline
        N Offline
        NET India
        wrote on last edited by
        #3

        Actually sir i'm getting error because there is no value in e.CommandName i mean it holds null. But why i'm not getting value please let me know

        1 Reply Last reply
        0
        • N NET India

          Hello Friends, I've a GridView in which i've taken a LinkButton as TemplateField and that's CommandName is "Play". And now i want to print the index value of the row accordingly the Play button of the GridView's row is clicked. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Play") { int index = Convert.ToInt32(e.CommandArgument); Response.Write(index); } } And i'm getting an error Input string was not in a correct format"

          S Offline
          S Offline
          sepel
          wrote on last edited by
          #4

          You may not assign any value to you'r LinkButton. And it can't Convert Null to int32. ;)

          sepel

          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