hello,
There may be a couple of reasons.
1) May be session time is less... try to increase session time
2) May be in DataBase call may the connection timed out. To prevent that one please increase that value
Place this line in your code (above function)
cmd.CommandTimeout = 5000;