سلام استاد
کد اینه :
private void Page_Load(object sender, System.EventArgs e)
{
string strcon=System.Configuration.ConfigurationSettings. AppSettings["str_connection"];
this.sqlCon.ConnectionString=strcon;
this.sqlCom.Connection=sqlCon;
this.Label1.Visible=false;
this.Label2.Visible=false;
this.Button1.Visible=true;
this.Buttonup.Visible=false;
this.sqlCon.Open();
this.sqlCom.CommandText="select * from type";
this.sqlDataA.Fill(dataSet2);
this.DropDownList2.DataBind();
this.DropDownList2.DataTextField="typename";
this.DropDownList2.DataValueField="typecode";
this.sqlCom.CommandText="select * from cs";
this.sqlDataA.Fill(dataSet3);
this.DropDownList1.DataTextField="csname";
this.DropDownList1.DataValueField="cscode";
this.DropDownList1.DataBind();
this.sqlCon.Close();
}
private void Button1_Click(object sender, System.EventArgs e)
{
if(this.TextBox3.Text.Length.Equals(0) )
{
this.Label1.Visible=true;
this.Label2.Visible=true;
}
else
{
this.sqlCon.Open();
this.sqlCom.CommandText="insert products values ('"
+this.TextBox3.Text
+"',N'"
+this.TextBox1.Text
+"','"
+this.DropDownList2.SelectedItem.Value.ToString 0;).Trim()
+"','"
+this.DropDownList1.SelectedItem.Value.ToString 0;).Trim()
+"',N'"
+this.TextBox2.Text
+"' )";
this.sqlCom.ExecuteNonQuery();
this.sqlCon.Close();
this.TextBox2.Text=null;
this.TextBox1.Text=null;
this.TextBox3.Text=null;
this.dataSet1.Clear();
this.Label1.Visible=false;
this.Label2.Visible=false;
}
}