using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient ;
using System.Web;
public partial class _Default : System.Web.UI.Page
{
static DataTable dtvalues =new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
// dtvalues.Columns.Clear();
if (!Page.IsPostBack)
{
createdatatable();
}
else
{
}
}
protected void createdatatable()
{
dtvalues.Columns.Clear();
dtvalues.Columns.Add("Name");
dtvalues.Columns.Add("Middel Name");
dtvalues.Columns.Add("Last Name");
dtvalues.Columns.Add("Address");
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "" && TextBox2.Text == "" && TextBox3.Text == "" && TextBox4.Text == "")
{
}
else
{
DataRow drvalues = dtvalues.NewRow();
drvalues["Name"] = TextBox1.Text;
drvalues["Middel Name"] = TextBox2.Text;
drvalues["Last Name"] = TextBox3.Text;
drvalues["Address"] = TextBox4.Text;
dtvalues.Rows.Add(drvalues);
GridView1.DataSource = dtvalues;
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox1.Focus();
}
}
}
this is my code after inserting values in to text box when we clicking on button 1 values from textboxes enters into grideview like this we can enters n numbers of values but the problem is while in beetween we are clicking on the refresh button of browser the last inserted record insrted again which is not wanted to do
hirenpatel53
-1
Posting Whiz in Training
Recommended Answers
Jump to PostI don't know the exact solution but I think it's ok. It should be like that. Because you click button and give some job and F5 repeat last job.
All 4 Replies
kad1r
0
Newbie Poster
hirenpatel53
-1
Posting Whiz in Training
reach_yousuf
2
Junior Poster
Lusiphur
185
Practically a Posting Shark
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.