Input string was not in a correct format. in Rowcommand of a GridView
-
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"
-
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"
.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.
-
.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.
-
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"