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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Sep 15, 2013, 1:21 PM
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 = "";
}
}
}
mohan kumarPosted Sep 15, 2013, 9:02 PM
Thanks for answering my question. I like your Proactiveness..Keep it up.
Sunny SharmaPosted Sep 15, 2013, 7:39 AM
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.