Click here to Skip to main content
15,894,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "insert tbstudent values(@q,@w,@ww)";
cmd.Connection = con;
cmd.Parameters.Add("@board_m", SqlDbType.VarChar, 50).Value = TextBox9.Text;
cmd.Parameters.Add("@q", SqlDbType.VarChar, 50).Value = TextBox10.Text;
cmd.Parameters.Add("@w", SqlDbType.Float).Value = TextBox11.Text;
cmd.Parameters.Add("@ww", SqlDbType.Float).Value = TextBox12.Text;
float m1 = Convert.ToInt32(TextBox11.Text); float m2 = Convert.ToInt32(TextBox12.Text);
float m3 = (m1 / m2) * 100;
cmd.Parameters.Add("@per_m", SqlDbType.Float).Value = m3; Label1.Visible = true; Label1.Text = Convert.ToString(m3);
cmd.ExecuteNonQuery();
cmd.Dispose();
}

Suppose i have 4 fields:
Name: textbox
Class: textbox
Marks obtained: textbox
Maximum marks: textbox
%age: label1
If the result of student id not declared then it should leave blank to the textboxes
else
Its %age is displayed in label1

please help me.
Posted
Updated 6-Mar-11 5:43am
v8
Comments
m@dhu 6-Mar-11 7:32am    
You have deleted and came back with same question. Use improve question always to update it.
m@dhu 6-Mar-11 7:33am    
what error are you getting?
Shagun Bansal 6-Mar-11 7:36am    
Error is: "Input string was not in a correct format."
Richard MacCutchan 6-Mar-11 7:38am    
See my entry below.
Richard MacCutchan 6-Mar-11 7:38am    
Why are you using Convert.ToInt32() to get a float value? Use Convert.ToSingle().

More importantly what is your question?

1 solution

Disable the button until all required fields have been entered.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900