Click here to Skip to main content
15,902,636 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello sir,

I want show loan tenure entries in gridview, i mean suppose i have loan for 36 month and EMI per month is 20000 and my loan starts from Aug 2013 To Aug 2015, so all entries must show in gridview like

Output:
EMIPerMonth | Month | Year
20000          Aug     2013
20000          Sep     2013
           till
20000          Aug     2015
Posted
Updated 10-Aug-13 10:14am
v2
Comments
Dholakiya Ankit 10-Aug-13 4:26am    
gud q with no solution what you have tried for this one?
yogeshkansete 10-Aug-13 4:44am    
yes i tried one solution but it is only for loan tenure less than 2 yr

if (txtYears.Text != "" && txtLoanAmount.Text != "" && txtLoanPercent.Text != "")
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("tranMonthNo", typeof(string)));
dt.Columns.Add(new DataColumn("tranMonthName", typeof(string)));
dt.Columns.Add(new DataColumn("tranYear", typeof(string)));
dt.Columns.Add(new DataColumn("EMIperMonth", typeof(string)));

if (Convert.ToInt32(txtYears.Text) > 0)
{
string mnth = "";
string mnthno = "";
string year = "";
int b = Convert.ToInt32(lblmonthno.Value) + Convert.ToInt32(txtYears.Text); // txtYears.Text = period of month
for (int i = Convert.ToInt32(lblmonthno.Value); i < b; i++)
{
if (i <= 12)
{
if (i == 1)
{
mnth = "January";
mnthno = "1";
}
else
if (i == 2)
{
mnth = "February";
mnthno = "2";
}
else
if (i == 3)
{
mnth = "March";
mnthno = "3";
}
else
if (i == 4)
{
mnth = "April";
mnthno = "4";
}
else
if (i == 5)
{
mnth = "May";
mnthno = "5";
}
else
if (i == 6)
{
mnth = "June";
mnthno = "6";
}
else
if (i == 7)
{
mnth = "July";
mnthno = "7";
}
else
if (i == 8)
{
mnth = "August";
mnthno = "8";
}
else
if (i == 9)
Maciej Los 10-Aug-13 16:43pm    
What a bad design... Sorry. You should works on dates. Using String.Format(...) you'll get the same. See my answer.
yogeshkansete 13-Aug-13 3:53am    
thank you it works
Maciej Los 13-Aug-13 4:26am    
You're welcome ;)

1 solution

First of all, please read my comment.

Here is an example how to process with dates:
C#
DateTime startdate = new DateTime(2013, 8, 1);
DateTime enddate = startdate.AddMonths(35);
DateTime currdate =startdate;
while (currdate <=enddate)
{
    Console.WriteLine("MonthNo: {0}, MonthName: {1}, Year: {2}", currdate.Month.ToString(), currdate.ToString("MMMM"), currdate.Year.ToString());
    currdate = currdate.AddMonths(1) ;
}
Console.ReadKey();
 
Share this answer
 
v3

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