Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if (e.CommandName == "Delete")
{
int index = Convert.ToInt32(e.CommandArgument);
GridView1.Rows[index].Visible = false;
}

I wrote this.But it's showing "Input string was not in a correct format." instead of storing row position to index.
Posted
Comments
BELGIUMsky 20-Mar-14 5:32am    
Can you tell more?
like an example of the link button you talk about?

Edit:
With this i mean what commandName / commandParameter and so on did you give the link button
Member 10675393 15-Apr-14 2:49am    
<asp:LinkButton ID="LinkButton1" CommandName="Delete" runat="server" Text="Delete" />

This the link button. While clicking this corresponding record should lose the visibility
BELGIUMsky 16-Apr-14 2:33am    
You use e.CommandArgument.
but you don't set an argument in your linkbutton
VICK 20-Mar-14 6:41am    
Do have a look HERE for a similar kind of question.

There are 2 possible reason for the error :-

1. In The Below Code check if e.CommandArgument returns Integer
int index = Convert.ToInt32(e.CommandArgument);

2. Check if the index supplied is not less than 0 or not negative
GridView1.Rows[index].Visible = false;
 
Share this answer
 
first check whether you are getting e.CommandArgument an integer or not.
one more thing is for deleting a row, use GridView1.DeleteRow(index);
 
Share this answer
 
Comments
VICK 20-Mar-14 6:40am    
I Think OP wants to hide the row, not to delete.
Member 10675393 15-Apr-14 2:55am    
Yes of course. Record should not be deleted. It should Hiden
Naz_Firdouse 20-Mar-14 9:16am    
I clearly mentioned that if he wants to delete it, he can use DeleteRow method...
VICK 21-Mar-14 1:25am    
But still that would be considered as Off Topic. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900