コード例 #1
0
    protected void Save(object sender, EventArgs e)
    {
        string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

        using (SqlConnection Conn = new SqlConnection(con))
        {
            SqlCommand cmd = new SqlCommand("dbo.AddArticles", Conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Cat_ID", DropDownList_categories.SelectedValue);
            cmd.Parameters.AddWithValue("@Art_Title", txt_NAME.Text);
            cmd.Parameters.AddWithValue("@Description", txt_DESC.Text);

            Conn.Open();
            cmd.ExecuteNonQuery();
            Conn.Close();
        }
        txt_NAME.Text = "";
        DropDownList_categories.DataBind();
        txt_DESC.Text = "";
    }
コード例 #2
0
 protected void Restore(object sender, EventArgs e)
 {
     txt_NAME.Text = "";
     DropDownList_categories.DataBind();
     txt_DESC.Text = "";
 }