I’m trying to remove a row from my gridview manually, because for some reason, when I delete the item from the database and databind, the gridview still isn’t updating. Here is the code I am using:
try
{
gvCertifications.DeleteRow(int.Parse(commandArgs[1]));
}
catch (HttpException)
{
//error
}
and for some reason, I’m always hitting that HttpException? I’ve tried placing this command both before and after my DataBind (because MSDN says that the HttpException occurs when the gridview isn’t bound to a datasource)
The gridview is already bound to a datasource when it is loaded, so I don’t know why I would be getting this exception…
Also, in case it helps, here is how I get commandArgs[]:
String[] commandArgs = e.CommandArgument.ToString().Split('|'); //before in same function as the try/catch block
and here are the commandargs from the .aspx file:
CommandArgument='<%#Eval("ThisId") + "|" + Container.DataItemIndex %>'
While it doesn’t necessarily answer my question, it solves the issue I was trying to hack around with it:
Gridviews have predefined commands set up, such as ‘select’, ‘edit’, and ‘delete’. When I try to define my own event to run with the command name ‘delete’, the program will try and run parts of my event alongside it’s predefined event. This is what has been causing issues.