Home > DeveloperSection > Forums > not able to store data in database
ashwini dharamsale
ashwini dharamsale

Total Post:1

Points:7
Posted on    January-21-2014 6:20 AM

 ASP.Net ASP.Net 
Ratings:


 0 Reply(s)
 2616  View(s)
Rate this:
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>");
        }
    }


Don't want to miss updates? Please click the below button!

Follow MindStick