how to solve Object reference not set to an instance of an object
         protected void filmfestival_grid_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                
               
                lblerror.Visible = true;
        
                TextBox txt_fromdate1 = (TextBox)filmfestival_grid.Rows[e.RowIndex].FindControl("txt_fromdate");//.Text.Trim();
                TextBox txt_todate1 = (TextBox)filmfestival_grid.Rows[e.RowIndex].FindControl("txt_todate");//.Text.Trim();
               
                DateTime date1 = (DateTime.Parse(dateformat_mmdd(txt_fromdate1.Text)));
                DateTime date2 = (DateTime.Parse(dateformat_mmdd(txt_todate1.Text)));
        
                
                if ((date1) <= (date2))
                {
                    con.Open();
        
                    com = new SqlCommand("BTNN_MovieDB_Festival_Details_Update", con);
                    com.CommandType = CommandType.StoredProcedure;
                    //com.Parameters.AddWithValue("@id_dfestival", SqlDbType.VarChar).Value = id.ToString();
                    com.Parameters.AddWithValue("@id_festival", SqlDbType.VarChar).Value = Request.Params["id_festival"];
                   
                    com.Parameters.Add(new SqlParameter("@fromdate", SqlDbType.VarChar)).Value =dateformat_mmdd(txt_fromdate.Text.ToString().Trim());
                    com.Parameters.Add(new SqlParameter("@todate", SqlDbType.VarChar)).Value = dateformat_mmdd(txt_todate.Text.ToString().Trim());
                    com.ExecuteNonQuery();
                    con.Close();
                    // lblerror.Text = "It Updated Successully";
        
                    filmfestival_grid.EditIndex = -1;
        
                    showdata();
        
                }
                else if ((date1) > (date2))
                {
                    lblerror.Text = "ToDate should be greater than FromDate";
        
        
                }
        
        	}
        	public void showdata()
            {
                SqlDataAdapter sda = new SqlDataAdapter("select * from BTNN_MovieDB_Festival_Details where Syncoperation <>'D'", con);
                ds = new DataSet();
        
                sda.Fill(ds);
                filmfestival_grid.DataSource = ds;
                filmfestival_grid.DataBind();
        
        
            }
        
            public string dateformat_mmdd(string DateDDMM)
            {
                string retDate = "";
        
                if (DateDDMM.Length > 0)
                {
                    char[] splitter = { '/' };
                    string[] InDate_arr = new string[3];
                    InDate_arr = DateDDMM.Split(splitter);
        
                    if (InDate_arr.GetUpperBound(0) > 0)
                    {
                        retDate = InDate_arr[1].Trim().ToString() + "/" + InDate_arr[0].Trim().ToString() + "/" + InDate_arr[2].Trim().ToString();
                    }
                }
        
                return retDate.ToString();
            }
    Findcontrols is im took two ajax calender txt_fromdate and txt_todate it's name respectively
    i have a above code whenever i run this it give me object reference not set to as instance 
    here is my error:
    
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    
    Source Error:
    
    Line 191:       // Response.Write("out="+txt_fromdate.Text+"<br/>");
    Line 192:        //Response.End();
    Line 193:        DateTime date1 = (DateTime.Parse(dateformat_mmdd(txt_fromdate.Text)));
    Line 194:        DateTime date2 = (DateTime.Parse(dateformat_mmdd(txt_todate.Text)));
    Line 195:
    
    
    Source File: e:\application server\BT-Bollywood-Trade\system\admin\MovieDB_Festival_Update.aspx.cs    Line: 193
    
    Stack Trace:
    
    [NullReferenceException: Object reference not set to an instance of an object.]
       system_MovieDB_Festival_Update.filmfestival_grid_RowUpdating(Object sender, GridViewUpdateEventArgs e) in e:\application server\BT-Bollywood-Trade\system\admin\MovieDB_Festival_Update.aspx.cs:193
       System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +133
       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +720
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


how to solve Object reference not set to an instance of an object
===

         protected void filmfestival_grid_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                
               
                lblerror.Visible = true;
        
                TextBox txt_fromdate1 = (TextBox)filmfestival_grid.Rows[e.RowIndex].FindControl("txt_fromdate");//.Text.Trim();
                TextBox txt_todate1 = (TextBox)filmfestival_grid.Rows[e.RowIndex].FindControl("txt_todate");//.Text.Trim();
               
                DateTime date1 = (DateTime.Parse(dateformat_mmdd(txt_fromdate1.Text)));
                DateTime date2 = (DateTime.Parse(dateformat_mmdd(txt_todate1.Text)));
        
                
                if ((date1) <= (date2))
                {
                    con.Open();
        
                    com = new SqlCommand("BTNN_MovieDB_Festival_Details_Update", con);
                    com.CommandType = CommandType.StoredProcedure;
                    //com.Parameters.AddWithValue("@id_dfestival", SqlDbType.VarChar).Value = id.ToString();
                    com.Parameters.AddWithValue("@id_festival", SqlDbType.VarChar).Value = Request.Params["id_festival"];
                   
                    com.Parameters.Add(new SqlParameter("@fromdate", SqlDbType.VarChar)).Value =dateformat_mmdd(txt_fromdate.Text.ToString().Trim());
                    com.Parameters.Add(new SqlParameter("@todate", SqlDbType.VarChar)).Value = dateformat_mmdd(txt_todate.Text.ToString().Trim());
                    com.ExecuteNonQuery();
                    con.Close();
                    // lblerror.Text = "It Updated Successully";
        
                    filmfestival_grid.EditIndex = -1;
        
                    showdata();
        
                }
                else if ((date1) > (date2))
                {
                    lblerror.Text = "ToDate should be greater than FromDate";
        
        
                }
        
        	}
        	public void showdata()
            {
                SqlDataAdapter sda = new SqlDataAdapter("select * from BTNN_MovieDB_Festival_Details where Syncoperation <>'D'", con);
                ds = new DataSet();
        
                sda.Fill(ds);
                filmfestival_grid.DataSource = ds;
                filmfestival_grid.DataBind();
        
        
            }
        
            public string dateformat_mmdd(string DateDDMM)
            {
                string retDate = "";
        
                if (DateDDMM.Length > 0)
                {
                    char[] splitter = { '/' };
                    string[] InDate_arr = new string[3];
                    InDate_arr = DateDDMM.Split(splitter);
        
                    if (InDate_arr.GetUpperBound(0) > 0)
                    {
                        retDate = InDate_arr[1].Trim().ToString() + "/" + InDate_arr[0].Trim().ToString() + "/" + InDate_arr[2].Trim().ToString();
                    }
                }
        
                return retDate.ToString();
            }
    Findcontrols is im took two ajax calender txt_fromdate and txt_todate it's name respectively
    i have a above code whenever i run this it give me object reference not set to as instance 
    here is my error:
    
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    
    Source Error:
    
    Line 191:       // Response.Write("out="+txt_fromdate.Text+"<br/>");
    Line 192:        //Response.End();
    Line 193:        DateTime date1 = (DateTime.Parse(dateformat_mmdd(txt_fromdate.Text)));
    Line 194:        DateTime date2 = (DateTime.Parse(dateformat_mmdd(txt_todate.Text)));
    Line 195:
    
    
    Source File: e:\application server\BT-Bollywood-Trade\system\admin\MovieDB_Festival_Update.aspx.cs    Line: 193
    
    Stack Trace:
    
    [NullReferenceException: Object reference not set to an instance of an object.]
       system_MovieDB_Festival_Update.filmfestival_grid_RowUpdating(Object sender, GridViewUpdateEventArgs e) in e:\application server\BT-Bollywood-Trade\system\admin\MovieDB_Festival_Update.aspx.cs:193
       System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +133
       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +720
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

