本文介绍了textboxged text of textbox:问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void updatecareplan()
        {
           TextBox thisTextBox = (TextBox)NamingContainer;
            GridViewRow thisGridViewRow = (GridViewRow)thisTextBox.NamingContainer;
            int row = thisGridViewRow.RowIndex;

            string ParameterId = Convert.ToString(grdcareplan.DataKeys[row].Values[0]);
            string strid = Convert.ToString(grdcareplan.DataKeys[row].Values[1]);

            TextBox txttargetvalue = (TextBox)grdcareplan.Rows[row].FindControl("txttargetvalue");

            //TextBox txtlastdate = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txtlastdate");

            //TextBox txtresult = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txtresult");
            TextBox txttestdate = (TextBox)grdcareplan.Rows[row].FindControl("txttestdate");
            TextBox txttestresult = (TextBox)grdcareplan.Rows[row].FindControl("txttestresult");

            DropDownList ddlMeasurementFrequency = (DropDownList)grdcareplan.Rows[row].FindControl("ddlMeasurementFrequency");
            //   DropDownList ddlselectdisease = (DropDownList)grdcareplan.Rows[e.RowIndex].FindControl("ddlselectdisease");
            TextBox txtnextduedate = (TextBox)grdcareplan.Rows[row].FindControl("txtnextduedate");

            TextBox txtremarks = (TextBox)grdcareplan.Rows[row].FindControl("txtremarks");
            DateTime testdt = DateTime.ParseExact(txttestdate.Text, "yy/dd/MM", null);
            //DateTime lastdate = DateTime.ParseExact(txtlastdate.Text, "yy/dd/MM", null);
            DateTime nextdate = DateTime.ParseExact(txtnextduedate.Text, "yy/dd/MM", null);
            // DateTime lastdate = Convert.ToDateTime(txtlastdate.Text);

            MySqlConnection strConnection = null;

            MySqlCommand strCommand = null;
            try
            {
                strConnection = new MySqlConnection();
                strConnection.ConnectionString = StrConn;
                strConnection.Open();
                strCommand = new MySqlCommand();
                strCommand.Connection = strConnection;


                strCommand.CommandType = CommandType.StoredProcedure;
                strCommand.CommandText = "UpdateCarePlan1";
                strCommand.Parameters.AddWithValue("_Target_value", txttargetvalue.Text.ToString());
                strCommand.Parameters.AddWithValue("_Current_Test_Date", testdt);
                strCommand.Parameters.AddWithValue("_Test_Result", txttestresult.Text.ToString());
                //strCommand.Parameters.AddWithValue("_Last_date", lastdate);
                //strCommand.Parameters.AddWithValue("_Result", txtresult.Text.ToString());
                strCommand.Parameters.AddWithValue("_Measurement_Frequency", ddlMeasurementFrequency.SelectedItem.Text.ToString());
                //strCommand.Parameters.AddWithValue("_disease_Id", ddlselectdisease.SelectedValue);
                strCommand.Parameters.AddWithValue("_Next_Due_Date", nextdate);
                //strCommand.Parameters.AddWithValue("_Remarks", txtremarks.Text.ToString());
                //strCommand.Parameters.AddWithValue("_Tenant_Id", Convert.ToInt32(Session["Tenantid"]));
                //strCommand.Parameters.AddWithValue("_Branch_Id", Convert.ToInt32(Session["Branchid"]));
                strCommand.Parameters.AddWithValue("_ParameterId", ParameterId);
                strCommand.Parameters.AddWithValue("_Patient_Id", Convert.ToInt32(Session["DiagnosisClickId"]));
                strCommand.Parameters.AddWithValue("_Modified_Date", DateTime.Now);
                strCommand.Parameters.AddWithValue("_date", DateTime.Now);
                strCommand.Parameters.AddWithValue("_Modified_By", Convert.ToInt32(Session["Doc_Id4rmLogin"]));
                strCommand.Parameters.AddWithValue("_Tenant_Id", Convert.ToInt32(Session["Tenantid"]));
                strCommand.Parameters.AddWithValue("_Branch_Id", Convert.ToInt32(Session["Branchid"]));
                //strCommand.Parameters.AddWithValue("_Id", strid);
                //strCommand.Parameters.AddWithValue("_SubTypeCode", "BIOMADE");
                //strCommand.Parameters.AddWithValue("_Active",0);
                //strCommand.Parameters.AddWithValue("_SubTypeCode", Convert.ToString(ViewState["BIOMADE"]));
                strCommand.ExecuteNonQuery();

                grdcareplan.EditIndex = -1;

                BindCarePlan();
                ModalPopupExtender1.Show();
                Biomade.Visible = true;
            }
            catch (Exception ex)
            {

                obj.InfoEntry(DateTime.Now + "     " + " BindCarePlan" + "     " + "HomeHealthCare.aspx" + "     " + ex.Message, "");
                obj.InfoEntry(DateTime.Now + "     " + ex.StackTrace, "");
                Session["strerrormsg"] = DateTime.Now + "     " + " BindCarePlan" + "     " + "HomeHealthCare.aspx" + "     " + ex.Message;
                Session["strerrortrace"] = DateTime.Now + "     " + ex.StackTrace;
                Response.Redirect("ErrorPage.aspx");
            }
            finally
            {
                strCommand.Dispose();
                strConnection.Close();
            }
        }




protected void txtnextduedate_TextChanged(object sender, EventArgs e)
       {
           updatecareplan();
       }





在这一行给出错误



giving error at this line

GridViewRow thisGridViewRow = (GridViewRow)thisTextBox.NamingContainer;



对象refrance没有设置对象的实例


that object refrance not set an instance of an object

推荐答案

protected void txtnextduedate_TextChanged(object sender, EventArgs e)
{
    updatecareplan(sender);
}



和更新方法定义如:


and update method defination like:

private static void updatecareplan(object sender)
{
    TextBox txt = (TextBox)sender;
    GridViewRow row = (GridViewRow)txt.NamingContainer;
    int index = row.RowIndex;
    // do your code here
}





这可以帮到你



this may help you


这篇关于textboxged text of textbox:问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 08:16