Regarding grid view issue
I want to read already the no of records in a table. If a new record is added to the table, in ASP.NET Web application , it has to display a message like " One record Inserted"
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 15, 2013, 9:21 AM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Insert_success_javascript
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void btn_insert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
com = new SqlCommand("insert into employee values(@name,@address,@sal)", con);
com.Parameters.AddWithValue("@name", txtname.Text);
com.Parameters.AddWithValue("@address", txtaddress.Text);
com.Parameters.AddWithValue("@sal", txtsal.Text);
int result = com.ExecuteNonQuery();
if (result == 1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txtname.Text + "')", true);
}
com.Dispose();
con.Close();
clear();
}
void clear()
{
txtname.Text = "";
txtaddress.Text = "";
txtsal.Text = "";
}
}
}
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 15, 2013, 3:39 AM EDT
I guess the part of your question-"I want to read already the no of records in a table. If a new record is added to the table, in ASP.NET Web application " doesn't make sense. Can you please explain a little more.
mohan kumar55 reputationPosted Sep 15, 2013, 5:02 PM EDT
Thanks for answering my question. I like your Proactiveness..Keep it up.