G
Guest
Hi,
I have an ASP.NET page which uses C#. When the user clicks submit button,
all information goes to the SQL database & the page is postback to itself.
Now, I have a label whose text increments by 1 each time the submit button
is hit. This label is compared with a number the user enters in the txtRec
text box. But for the first hit of submit button, it dispalys 1 in the label.
But for subsequent hits of submit button, it still shows 1 !!!
I have initialized the value of label (in code) as 0. can it be aomething to
do with the controls' viewstate property?
My code is::
protected int x;
protected System.Web.UI.WebControls.TextBox txtTotalRec;
protected int y;
protected System.Web.UI.WebControls.Label lblDone;
protected int i=0;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
txtActivationDate.Text= System.DateTime.Today.Date.ToString();
}
private void btnSubmit1_Click(object sender, System.EventArgs e)
{
sqlCommand1.Parameters["@a"].Value= txtCompany.Text;
sqlCommand1.Parameters["@b"].Value=
System.DateTime.Parse(txtActivationDate.Text);
sqlCommand1.Parameters["@p"].Value= txtMrc.Text;
sqlCommand1.Parameters["@r"].Value= Int64.Parse(txtMin.Text);
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
i=i+1;
lblHold.Text=i.ToString();
x=int.Parse(lblHold.Text);
y= int.Parse(txtTotalRec.Text);
if(x<y)
{
fn();
}
else
{
lblDone.Text="You have entered all the records.";
}
private void fn()
{
lblConfirm.Visible= true;
txtMrc.Text=""; txtMin.Text="0";
}
I have an ASP.NET page which uses C#. When the user clicks submit button,
all information goes to the SQL database & the page is postback to itself.
Now, I have a label whose text increments by 1 each time the submit button
is hit. This label is compared with a number the user enters in the txtRec
text box. But for the first hit of submit button, it dispalys 1 in the label.
But for subsequent hits of submit button, it still shows 1 !!!
I have initialized the value of label (in code) as 0. can it be aomething to
do with the controls' viewstate property?
My code is::
protected int x;
protected System.Web.UI.WebControls.TextBox txtTotalRec;
protected int y;
protected System.Web.UI.WebControls.Label lblDone;
protected int i=0;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
txtActivationDate.Text= System.DateTime.Today.Date.ToString();
}
private void btnSubmit1_Click(object sender, System.EventArgs e)
{
sqlCommand1.Parameters["@a"].Value= txtCompany.Text;
sqlCommand1.Parameters["@b"].Value=
System.DateTime.Parse(txtActivationDate.Text);
sqlCommand1.Parameters["@p"].Value= txtMrc.Text;
sqlCommand1.Parameters["@r"].Value= Int64.Parse(txtMin.Text);
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
i=i+1;
lblHold.Text=i.ToString();
x=int.Parse(lblHold.Text);
y= int.Parse(txtTotalRec.Text);
if(x<y)
{
fn();
}
else
{
lblDone.Text="You have entered all the records.";
}
private void fn()
{
lblConfirm.Visible= true;
txtMrc.Text=""; txtMin.Text="0";
}