Quote:
Please give Me solution As soon as possible
We can't. We have no access to your data, or the actual source, so there isn't anything we can do as you need the code running with the actual data in order to work out what might be wrong.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
And do yourself a big favour: Stop swallowing exceptions. When you write code like this:
try
{
...
}
catch {}
You throw away all of the information you could use to fix a problem: the exception detail. Worse, you have no idea that an error occurred in the first place, let alone what line it might have happened on, so you can't even strat to fix it at the early stages when it's easiest.
Log them, show them on the debug console, do something useful with them - or remove your
try ... catch
block entirely as it just hiding problems until they become much, much worse.