Hello Frends I am getting an error. The details are follows,
ERROR:
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 36: if (rdr.Read())
Line 37: {
[COLOR="Red"][B]Line 38: matured_month = Convert.ToInt32(rdr.GetString(0));[/B][/COLOR]
Line 39: matured_year = Convert.ToInt32(rdr.GetString(1));
Line 40: conn.Close();
CODE:
protected void Page_Load(object sender, EventArgs e)
{
int cu_month = Convert.ToInt32(DateTime.Now.Month.ToString());
int cu_year=Convert.ToInt32(DateTime.Now.Year.ToString());
int matured_month=0;
int matured_year=0;
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM customer_details where adjustable_date like '%/%'", conn);
adapter.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
conn.Close();
foreach (GridViewRow row in GridView1.Rows)
{
conn.Open();
SqlCommand cmd = new SqlCommand("select substring(adjustable_date,4,2),substring(adjustable_date,7,4) from customer_details where customer_id='" + GridView1.DataKeys[row.RowIndex].Value.ToString() + "' ", conn);
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
[COLOR="Red"]matured_month = Convert.ToInt32(rdr.GetString(0));[/COLOR]
matured_year = Convert.ToInt32(rdr.GetString(1));
conn.Close();
}
if (cu_month == matured_month && cu_year == matured_year)
{
CheckBox checkbox = (CheckBox)row.FindControl("chkRows");
checkbox.Checked = true;
row.BackColor = System.Drawing.Color.Yellow;
}
if (cu_month + 1 == matured_month && cu_year == matured_year)
{
CheckBox checkbox = (CheckBox)row.FindControl("chkRows");
checkbox.Checked = true;
row.BackColor = System.Drawing.Color.YellowGreen;
}
}
Please tell me what I am doing wrong here. Why I am not getting any value in the line 38.