forum

Home / DeveloperSection / Forums / not able to store data in database

not able to store data in database

ashwini dharamsale358521-Jan-2014
protected void InsertNewRecord(object sender, EventArgs e)
    {
      
        try
        {
            string strName = GlobalClass.dt.Rows[0]["TechnisionName"].ToString();
            if (strName == "0")
            {
                GlobalClass.dt.Rows[0].Delete();
                GlobalClass.adap.Update(GlobalClass.dt);
            }
            TextBox txtDate = GridView1.FooterRow.FindControl("txtNewDate") as TextBox;
            TextBox txtName = GridView1.FooterRow.FindControl("txtNewName") as TextBox;
            TextBox txtTask = GridView1.FooterRow.FindControl("txtNewTask") as TextBox;
            TextBox txtStatus = GridView1.FooterRow.FindControl("txtNewStatus") as TextBox;
            TextBox txtRemark = GridView1.FooterRow.FindControl("txtNewRemark") as TextBox;
            DataRow dr = GlobalClass.dt.NewRow();
            dr["Date"] = txtDate.Text.Trim();
            dr["TechnisionName"] = txtName.Text.Trim();
            dr["Task"] = txtTask.Text.Trim();
            dr["Status"] = txtStatus.Text.Trim();
            dr["Remark"] = txtRemark.Text.Trim();
            GlobalClass.dt.Rows.Add(dr);
            GlobalClass.adap.Update(GlobalClass.dt);
            GridView1.ShowFooter = false;
            FillGridView();
            }
        catch
        {
             Response.Write("<script> alert('Record not added...') </script>");
        }
    }

Updated on 21-Jan-2014

Can you answer this question?


Answer

0 Answers

Liked By